Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 35470 Accepted Submission(s): 18897
12 1 3 3 4 0 7 3 8 15 19 15 20 10 15 8 18 6 12 5 10 4 14 2 9 0
5AC-code:
#include<stdio.h> #include<algorithm> using namespace std; struct arr { int b,e; }a[2001]; bool cmp(arr a,arr c) { if(a.e==c.e) return a.b>c.b; else return a.e<c.e; } int main() { int n,m,i,cont,temp; scanf("%d",&n); while(n--) { scanf("%d",&m); for(i=0;i<m;i++) scanf("%d%d",&a[i].b,&a[i].e); sort(a,a+m,cmp); cont=1; temp=a[0].e; for(i=0;i<m;i++) { if(a[i+1].b>temp) { i++; cont++; temp=a[i].e; } } printf("%d\n",cont); } return 0; }