Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <set>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- pair<int, int> a[n];
- for(int i = 0; i < n; i++) {
- cin >> a[i].second >> a[i].first;
- }
- sort(a, a + n);
- int zemen = a[0].first;
- // .first --> krajot na filmot
- // .second --> pocetok na filmot
- int res = 1;
- for(int i = 1; i < n; i++) {
- if(zemen <= a[i].second) {
- res++;
- zemen = a[i].first;
- }
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment