kananasgarli90

Movie Festival

Sep 19th, 2020
1,037
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define INF 2000000000
  4. int main()
  5. {
  6.     ios_base::sync_with_stdio(false);
  7.     cin.tie(NULL);
  8.  
  9.     vector<pair<int, int> > v;
  10.     int n, a, b, film = 1, finish_max;
  11.     cin>>n;
  12.     for(int i = 1; i <= n; i++){
  13.         cin>>a>>b;
  14.         v.push_back(make_pair(b, a));
  15.     }
  16.     sort(v.begin(), v.end());
  17.     finish_max = v[0].first;
  18.     for(int i = 1; i < v.size(); i++){
  19.         if(v[i].second >= finish_max){
  20.             film++;
  21.             finish_max = v[i].first;
  22.         }
  23.     }
  24.     cout<<film<<endl;
  25. }
  26.  
RAW Paste Data