joj2170

 2170: Travel


Result
TIME Limit
MEMORY Limit
Run Times
AC Times
JUDGE
3s
8192K
495
177
Standard
Mike want to travel around in the holiday, so he found some info. The travel starts at the time S and ends at F. Mike want to do more tavelling without any conflicts in time, namely, each travelling's start time is later than the last's end time. You are to write a program to help him calculate how many trips he can travel at most.

Input

The first line of each test is a integer N (0 < N <= 10000)-the number of the info. Then the next N line follows. Each line contains two integers S(start time)and F(end time).

Output

For each test you should output the number of the max trips .

Sample Input

2
10 15
16 17
2
10 15
15 16

Sample Output

2
1

Problem Source: evilll
This problem is used for contest: 25 
#include #include using namespace std; struct NODE {     int start;     int end; }; bool cmp(const NODE &n1,const NODE &n2) {     if(n1.end>n2.end)     return false;     else     return true; } NODE node[10005]; int main() {     freopen("in.txt","r",stdin);     int n;     while(scanf("%d",&n)==1)     {         for(int i=0;itemp)             {                 temp=node[i].end;                 count++;             }         }         printf("%d",count);     }     return 0; }
이 문제는 주로 앞의 종료 시간과 뒤의 시작 시간을 비교한다.

좋은 웹페이지 즐겨찾기