标签:
2 2 1 10 10 11 3 1 10 10 11 11 20
1 2
1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 using namespace std; 5 const int MAX = 10010; 6 struct f{ 7 int x,y; 8 }a[MAX]; 9 int cmp(f n,f m) 10 { 11 return n.y<m.y; 12 } 13 int main() 14 { 15 int T,n; 16 cin>>T; 17 while(T--) 18 { 19 cin>>n; 20 for(int i=0;i<n;i++) 21 cin>>a[i].x>>a[i].y; 22 sort(a,a+n,cmp); 23 int count=1; 24 int flag=0; 25 for(int i=0;i<n;i++) 26 { 27 if(a[i].x>a[flag].y) 28 { 29 flag=i; 30 count++; 31 } 32 } 33 cout<<count<<endl; 34 } 35 return 0; 36 }
标签:
原文地址:http://www.cnblogs.com/caterpillarofharvard/p/4230461.html