Advertisement
aryobarzan

SGU 133

May 28th, 2011
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <cstdio>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. pair<int,int> posts[16000+50];
  6. #define start first
  7. #define end second
  8.  
  9. int main()
  10. {
  11.   int n;
  12.   scanf("%d",&n);
  13.   for(int i=0;i<n;++i)
  14.     scanf("%d%d",&(posts[i].start),&(posts[i].end));
  15.   sort(posts,posts+n);
  16.   int red=0;
  17.   int max_seen=0;
  18.   for(int i=0;i<n;++i)
  19.     {
  20.       if(max_seen>posts[i].end)
  21.     red++;
  22.       max_seen=max(max_seen,posts[i].end);
  23.     }
  24.   printf("%d\n",red);
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement