#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++) {
cin >> a[i].first >> a[i].second;
swap(a[i].first, a[i].second);
}
int ans = 0;
vector<int> was(n + 1, 0);
vector<int> adj[n + 1];
sort(a.begin() + 1, a.end());
for(int i = n; i >= 1; i--) {
for(int j = i - 1; j >= 1; j--) {
if(abs(a[i].second - a[j].second) <= a[i].first - a[j].first) {
adj[i].push_back(j);
}
}
}
for(int i = n; i >= 1; i--) {
if(was[i]) {
continue;
}
was[i] = 1;
ans += 1;
for(auto it : adj[i]) {
was[it] = 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... |