poj1083 Moving Tables

注意corridor只有200个,第n个corridor对应room 2n-1和2n

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <algorithm>
 4 
 5 using namespace std;
 6 int corridor[201];
 7 bool compare(int a,int b)
 8 {
 9     return a>b;
10 }
11 int main()
12 {
13     int cases;
14     int n;
15     int from,to;
16     int start,end;
17     scanf("%d",&cases);
18     for(int a=0;a<cases;a++)
19     {
20         memset(corridor,0,sizeof(corridor));
21         scanf("%d",&n);
22         for(int i=0;i<n;i++)
23         {
24             scanf("%d %d",&from,&to);
25             if(from>to)
26             {
27                 int tmp=from;
28                 from=to;
29                 to=tmp;
30             }
31             start=(from+1)/2;
32             end=(to+1)/2;
33             for(int j=start;j<=end;j++)
34                 corridor[j]++;
35         }
36         sort(corridor+1,corridor+201,compare);
37         printf("%d\n",corridor[1]*10);
38     }
39 }
posted @ 2012-10-06 12:01  sidereal  Views(140)  Comments(0)    收藏  举报