#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Resident {
ll l, r;
bool operator<(const Resident& other) const {
if (l != other.l) return l < other.l;
return r > other.r;
}
};
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
vector<Resident> a(n);
for(int i=0; i<n; i++) {
ll x, e; cin >> x >> e;
a[i].l = x - e; a[i].r = x + e;
}
sort(a.begin(), a.end());
int ans = 0;
ll max_r = -2e18;
for(int i=0; i<n; i++) {
if (a[i].r > max_r) {
ans++;
max_r = a[i].r;
}
}
cout << ans << endl;
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... |