This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1000000000000000000
#define MOD 998244353
int32_t main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, ans = 1, idx = 0;
cin >> n;
int x[n], e[n], b[n];
pair<int, int> a[n];
for(int i = 0; i < n; i++) {
cin >> x[i] >> e[i];
a[i] = {x[i]+e[i], i};
}
sort(a, a+n);
for(int i = 0; i < n; i++) b[i] = INF;
for(int i = 0; i < n; i++) {
b[idx] = min(b[idx], x[a[i].second]-e[a[i].second]);
if(i == n-1 || a[i].first != a[i+1].first) idx++;
}
for(int i = idx-2; i >= 0; i--) b[i] = min(b[i], b[i+1]);
for(int i = 0; i < idx-1; i++) if(b[i] < b[i+1]) ans++;
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... |