Topic background
Quick Noip, yyy very nervous!
Title Description
Now there are n races on each big OJ, and the beginning and end of each game is known.
YYY believes that the more games you take, the better noip you will be able to test (fake)
So, he wanted to know how many games he could play.
Because YYY is Konjac Konjac, if you want to participate in a competition must finish, and can not participate in 2 or more competitions.
Input/output format
Input format:
The first line is an integer n, and the next n rows are 2 positive integers ai,bi (AI<BI), indicating when the game starts and ends.
Output format:
The maximum number of tournaments that an integer participates in.
Input and Output Sample input example # #:
30 22 41 3
Sample # # of output:
2
Description
For 20% of data, n≤10;
For 50% of data, n≤1000;
For 70% of data, n≤100000;
For 100% of data, n≤1000000,0≤ai
The start time for the second keyword is sorted in ascending order with the end time as the first keyword.
Each game is to participate as long as it determines whether the start time is after the end of the game.
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#defineMAXN 1000005using namespacestd;intN;structdata{intx, y;} A[MAXN];intF[MAXN];BOOLcmpConstData A,Constdata B) { if((A.Y<B.Y) | | ((A.Y==B.Y) && (a.x<b.x )))return 1;//Judgment End Time Else return 0; }intMain () {CIN>>N; for(intI=1; i<=n;++i) scanf ("%d%d",&a[i].x,&a[i].y); Sort (a+1, A +1+n,cmp); intk=0, l=0; for(intI=1; i<=n;++i)if(k<=a[i].x) {k=a[i].y; ++l; } cout<<M; return 0;}
Rokua P1803
Messy yyy.