daily pastebin goal
33%
SHARE
TWEET

Persian Party

a guest Mar 6th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main(){
  6.     int n;
  7.         cin>> n;
  8.        
  9.     int a[n], d[n], v=0;
  10.         for(int i=0; i<n; i++){
  11.             cin>> a[i];
  12.             cin>> d[i];
  13.         }
  14.     sort(a, a+n);
  15.     sort(d, d+n);
  16.    
  17.     for (int i=1; i<n; i++){   
  18.         if(a[i]<d[i-1]){
  19.             v++;   
  20.             for(int j=i-2; j>=0; j--){ 
  21.                 if(a[i]<d[j])
  22.                     v++;
  23.                 else
  24.                     break;
  25.             }
  26.         }
  27.     }
  28.     cout<<(v+n)*2;
  29. }
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