#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<pair<int,int>> a(n + 1);
for(int i = 1; i <= n; i++) {
int u, v;
cin >> u >> v;
a[i] = {u - v, u + v};
}
sort(a.begin(), a.end(), [&](pair<int, int> x, pair<int, int> y) {
if (x.first == y.first)
return x.second > y.second;
return x.first < y.first;
});
int ans = 0, best = - 1;
for(int i = 1; i <= n; i++) {
if(best < a[i].second) {
best = a[i].second;
ans += 1;
}
}
cout << ans;
}
# | 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... |