// #include <me>
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define pb push_back
#define int long long
#define fi first
#define se second
const int N = 3e5 + 5, M = 1e9 + 7, LG = 20;
int n , x , e;
void solve(){
cin >> n;
set<pair<int,int>> st;
set<int> hu,ht;
for (int i = 1 ; i <= n ; i++){
cin >> x >> e;
st.insert({-e,x});
hu.insert(x);
ht.insert(e);
}
if (ht.size() == 1){
cout << hu.size() << endl;
return;
}
int ans = 0;
while(st.size()){
e = (*(st.begin())).fi , x = (*(st.begin())).se; st.erase(*(st.begin()));
e = -e;
ans++;
vector<pair<int,int>> re;
for (auto i : st){
if (abs(i.se - x) <= e + i.fi){
re.pb(i);
}
}
while(re.size()){
st.erase(re.back());
re.pop_back();
}
}
cout << ans << endl;
}
signed main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int ts = 1;
// cin >> ts;
while(ts--){
solve();
}
}
| # | 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... |