#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define SS ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#pragma optimize("g", on)
#pragma GCC optimize("03")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,avx2,mmx,fma,avx,tune=native")
#define int long long
#define all(x) x.begin(),x.end()
#define F first
#define S second
using namespace std;
// using namespace __gnu_pbds;
// #define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
const int LG = 20,N = 1e6+1,inf = 1e18,MOD = 998244353;
const double eps = 1e-9;
int T;
void solve() {
int n;
cin>>n;
pair<int,int> p[n+1];
for(int i=1;i<=n;i++){
int x,e;
cin>>x>>e;
p[i]={x-e,x+e};
}
sort(p+1,p+n+1, [&](pair<int,int> a,pair<int,int> b){
if(a.F!=b.F) return a.F<b.F;
return a.S>b.S;
});
int mx=-inf,ans=0;
for(int i=1;i<=n;i++){
auto [x,y]=p[i];
if(mx<y) mx=y,ans++;
}
cout<<ans<<'\n';
return;
}
signed main() {
// freopen("deleg.in","r",stdin);
// freopen("deleg.out","w",stdout);
SS
int t = 1;
if (T) {
cin >> t;
}
while (t--) {
solve();
}
}
/*
e[i]>e[j]
if(x[i]>x[j]) x[i]-e[i]<=x[j]-e[j] -> x[i]+e[i]>=x[j]+e[j]
else x[i]+e[i]>=x[j]+e[j] -> x[i]-e[i]<=x[j]-e[j]
so x[i]-e[i]<=x[j]-e[j] && x[i]+e[i]>=x[j]-e[j]
e[j]<e[i]
x[i]+e[i] <= x[j]+e[j]
x[i]-e[i] >= x[j]-e[j]
x[i]-e[i] >= x[j]-e[j] && x[i]+e[i] <= x[j]+e[j]
*/
# | 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... |