fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int N = 1e6 + 3;
  6.  
  7. int n;
  8. pair<int, int> p[N];
  9.  
  10. void rotate_points(){
  11. for(int i = 0; i < n; ++i)
  12. p[i] = {p[i].first - p[i].second, p[i].first + p[i].second};
  13. }
  14.  
  15. int main(){
  16. ios::sync_with_stdio(false);
  17. cin.tie(NULL);
  18.  
  19. cin >> n;
  20. for(int i = 0; i < n; ++i)
  21. cin >> p[i].second >> p[i].first;
  22.  
  23. rotate_points();
  24. sort(p, p + n, [&](auto l, auto r){
  25. if(l.first != r.first)
  26. return l.first < r.first;
  27. return l.second > r.second;
  28. });
  29.  
  30. multiset<int> ms;
  31. for(int i = 0; i < n; ++i){
  32. auto it = ms.lower_bound(p[i].second);
  33. if(it != ms.end()) ms.erase(it);
  34. ms.insert(p[i].second);
  35. }
  36. cout << ms.size() << "\n";
  37. }
  38.  
Success #stdin #stdout 0s 5240KB
stdin
Standard input is empty
stdout
0