Advertisement
Josif_tepe

Untitled

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