#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
const int inf = 1e18;
signed main(){
ios::sync_with_stdio(0);
cin.tie(nullptr); cout.tie(nullptr);
int n;
cin >> n;
vector<pair<int, int>> v;
for(int i = 1, x, e; i <= n; ++i){
cin >> x >> e;
v.push_back({x - e, x + e});
}
// xi - xj <= ei - ej
// xi - ei <= xj - ej
// xi + ei >= ej + xj
sort(all(v), [&](pair<int, int> x, pair<int, int> y){
if(x.first == y.first) return x.second > y.second;
return x.first < y.first;
});
//v.erase(unique(v.begin(), v.end()), v.end());
vector<int> dp(n, 0);
dp[0] = 1;
for(int j = 0; j < n; ++j){
dp[j] = 1;
for(int i = j - 1; i >= 0; --i){
if(v[i].second >= v[j].second){
dp[j] = 0;
}
}
}
int sum = 0;
for(int j = 0; j < n; ++j) sum += dp[j];
cout << sum << "\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... |