Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- struct Pair {
- int m, h;
- } a[100500];
- bool cmp(Pair p1, Pair p2) {
- return p1.h < p2.h;
- }
- int main() {
- int n;
- cin >> n;
- for (int i = 1; i <= n; i++)
- cin >> a[i].m >> a[i].h;
- sort(a + 1, a + n + 1, cmp);
- int ans = 0;
- int mx = -1;
- for(int i = 1; i <= n; i++){
- if (a[i].m>mx){
- ans++;
- mx=a[i].h;
- }
- }
- cout << ans;
- return 0;
- }
Add Comment
Please, Sign In to add comment