askarulytarlan

Untitled

Feb 5th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. struct Pair {
  7. int m, h;
  8. } a[100500];
  9.  
  10. bool cmp(Pair p1, Pair p2) {
  11. return p1.h < p2.h;
  12. }
  13.  
  14. int main() {
  15. int n;
  16. cin >> n;
  17.  
  18. for (int i = 1; i <= n; i++)
  19. cin >> a[i].m >> a[i].h;
  20.  
  21. sort(a + 1, a + n + 1, cmp);
  22. int ans = 0;
  23. int mx = -1;
  24. for(int i = 1; i <= n; i++){
  25. if (a[i].m>mx){
  26. ans++;
  27. mx=a[i].h;
  28. }
  29. }
  30.  
  31. cout << ans;
  32. return 0;
  33.  
  34. }
Add Comment
Please, Sign In to add comment