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