daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Dec 8th, 2014 611 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<utility>
  3. #include<algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7. int total=1;
  8. int N,i,j;
  9.         cin >> N;
  10.         pair<long int,long int> pi[N];
  11.         for(i=0;i<N;i++)
  12.         {
  13.             cin >> pi[i].first >> pi[i].second;
  14.         }
  15.         sort(pi,pi+N);
  16. int x=0;
  17. int y=1;
  18. while(x<N-1)
  19. {
  20.     while(y<N)
  21.     {
  22.         if(pi[x].second<pi[y].first)
  23.         {
  24.  
  25.          x=y;
  26.          y=y+1;
  27.          total=total+1;
  28.         }
  29.     else if (pi[x].second>=pi[y].first && pi[x].second>pi[y].second)
  30.        {
  31.  
  32.         x=y;
  33.         y=y+1;
  34.        }
  35.        else
  36.         y=y+1;
  37.     }
  38.     x=x+1;
  39. }
  40. cout<<total<<"\n";
  41. return 0;
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top