#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int main() {
int n;
cin >> n;
vector<pair<int, int>> neg, pos;
for (int i = 0; i < n; i++) {
int x, e;
cin >> x >> e;
if (e-x < 0) neg.push_back({e-x, e+x});
else pos.push_back({e-x, e+x});
}
sort(neg.begin(), neg.end());
reverse(neg.begin(), neg.end());
indexed_set s;
int ans = 0;
for (int i = 0; i < neg.size(); i++) {
ans = max(ans, int(s.order_of_key(neg[i].second+1))+1);
s.insert(neg[i].second);
}
s.clear();
sort(pos.begin(), pos.end());
for (int i = 0; i < pos.size(); i++) {
ans = max(ans, int(s.order_of_key(pos[i].second+1))+1);
s.insert(pos[i].second);
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |