#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define int long long
#define double lld
typedef long long ll;
bool cmp(pair<int,int>p,pair<int,int>q){
if(p.first!=q.first){
return p.first<q.first;
}
return (p.second>q.second);
}
signed main(){
fastio; //judge();
int n; cin >> n;
vector<pair<int,int>>a(n);
for(int i = 0;i<n;i++) cin >> a[i].first >> a[i].second;
vector<pair<int,int>>alpha(n);
for(int i = 0;i<n;i++){
alpha[i].first = a[i].first - a[i].second;
alpha[i].second = a[i].first + a[i].second;
}
sort(alpha.begin(),alpha.end(),cmp);
int count = 1, close = alpha[0].second;
for(int i = 1;i<n;i++){
if(alpha[i].second>close){
count++; close = alpha[i].second;
}
}
cout << count;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |