Advertisement
Josif_tepe

Untitled

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