标签:
Description
Input
Output
Sample Input
Sample Output
1 #include<stdio.h> 2 #include<algorithm> 3 #include<string.h> 4 using namespace std; 5 struct time 6 { 7 int start; 8 int over; 9 } a[210]; 10 int cmp(time c,time b) 11 { 12 return c.start<b.start; 13 } 14 int vis[210]; 15 int main() 16 { 17 int t; 18 scanf("%d",&t); 19 while(t--) 20 { 21 memset(vis,0,sizeof(vis)); 22 int n; 23 scanf("%d",&n); 24 for(int i=0; i<n; i++) 25 scanf("%d%d",&a[i].start,&a[i].over); 26 for(int i=0;i<n;i++) 27 { 28 if(a[i].start>a[i].over) 29 { 30 int y=a[i].start; 31 a[i].start=a[i].over; 32 a[i].over=y; 33 } 34 if(a[i].start%2==1) 35 a[i].start=a[i].start/2+1; 36 else a[i].start/=2; 37 if(a[i].over%2==1) 38 a[i].over=a[i].over/2+1; 39 else 40 a[i].over/=2; 41 } 42 sort(a,a+n,cmp); 43 int step=0; 44 int temp; 45 for(int i=0; i<n; i++) 46 { 47 48 temp=a[i].over; 49 if(vis[i]==0) 50 { 51 step++; 52 for(int j=0; j<n; j++) 53 { 54 if(a[j].start>temp&&vis[j]==0) 55 { 56 temp=a[j].over; 57 vis[j]=1; 58 } 59 } 60 } 61 } 62 printf("%d\n",step*10); 63 } 64 }
标签:
原文地址:http://www.cnblogs.com/VectorLin/p/5216650.html