Advertisement
Josif_tepe

Untitled

Jun 1st, 2024
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.    pair<int, int> p[n];
  10.    
  11.     for(int i = 0; i < n; i++) {
  12.         int a, b;
  13.         cin >> a >> b;
  14.         p[i] = make_pair(b, a);
  15.     }
  16.     sort(p, p + n);
  17.     int vreme_na_zavrsuvanje = p[0].first;
  18.     int kolku_filmovi = 1;
  19.     for(int i = 1; i < n; i++) {
  20.         if(vreme_na_zavrsuvanje <= p[i].second) {
  21.             kolku_filmovi++;
  22.             vreme_na_zavrsuvanje = p[i].first;
  23.         }
  24.     }
  25.     cout << kolku_filmovi << endl;
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement