-
//zoj1029 Moving Tables
-
//Accepted 1029 C ++ 00:00.01 436K
-
#include <stdio.h>
-
#include <stdlib.h>
-
#include <algorithm>
-
using namespace std;
-
struct room{ int s; int t; } r[200];
-
int sort_function(const void *a, const void *b)
-
{
-
return (*(int *)a - *(int *)b);
-
}
-
void solve()
-
{
-
int i,j,n;
-
scanf ("%d",&n);
-
for (i=0; i<n; ++i) {
-
int s,t;
-
scanf ("%d %d",&s,&t);
-
if (s > t) swap(s,t);
-
r[i].s = (s+1)/2;
-
r[i].t = (t+1)/2;
-
}
-
qsort (r,n,sizeof(r[0]),sort_function);
-
int max = 0;
-
for (i=0; i<n; ++i) {
-
int cnt = 1, from = r[i].s, to = r[i].t;
-
for (j=0; j<n; ++j) {
-
if (i == j) continue;
-
if (r[j].s<=to && r[j].t>=from) {
-
if (from < r[j].s) from = r[j].s;
-
if (to > r[j].t) to = r[j].t;
-
cnt++;
-
}
-
}
-
if (cnt > max) max = cnt;
-
}
-
printf ("%d/n",10*max);
-
}
-
int main()
-
{
-
#ifndef ONLINE_JUDGE
-
freopen("1029.txt","r",stdin);
-
#endif
-
int test;
-
while (scanf ("%d",&test) != EOF)
-
while (test--)
-
solve();
-
#ifndef ONLINE_JUDGE
-
fclose(stdin);
-
#endif
-
return 0;
-
}
zoj1029 Moving Tables
最新推荐文章于 2018-06-22 22:27:09 发布