SHARE
TWEET

Untitled

a guest Feb 27th, 2020 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. ifstream f("reactivi.in");
  4. ofstream g("reactivi.out");
  5. int n,x[8005],y[8005];
  6.  
  7. int main()
  8. {
  9.     f>>n;
  10.     for(int i=1; i<=n; i++)
  11.         f>>x[i]>>y[i];
  12.     for(int i=1; i<n; i++)
  13.         for(int j=i+1; j<=n; j++)
  14.         {
  15.             if(x[i]>x[j])
  16.             {
  17.                 swap(x[i],x[j]);
  18.                 swap(y[i],y[j]);
  19.             }
  20.             else if(x[i]==x[j] )
  21.             {
  22.                 if(y[i]<y[j]) {swap(x[i],x[j]);
  23.                 swap(y[i],y[j]);}
  24.             }
  25.         }
  26.     int f1=1,xf,yf;
  27.     xf=x[1];
  28.     yf=y[1];
  29.     for(int i=2;i<=n;i++)
  30.     {
  31.         if(yf<x[i])
  32.         f1++,yf=y[i];
  33.         else yf=min(yf,y[i]);
  34.  
  35.     }
  36.     g<<f1;
  37.  
  38.  
  39.  
  40.     return 0;
  41. }
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