This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
struct numbers{
int l,r;
};
numbers v[N];
numbers pr;
int main(){
int n,i,x,e,ans;
cin>>n;
for(i = 0;i < n;i++){
cin>>x>>e;
v[i].l = x - e;
v[i].r = x + e;
}
sort(v,v + n,[&](numbers a,numbers b){
if(a.l == b.l)return a.r > b.r;
return a.l < b.l;
});
ans = n;
int maxx = -2e9;
for(i = 0;i < n;i++){
if(pr.l == v[i].l && v[i].r == pr.r){ans--;continue;}
pr = v[i];
//cout<<v[i].l<<' '<<v[i].r<<'\n';
if(maxx >= v[i].r)ans--;
maxx = max(maxx,v[i].r);
}
cout<<ans;
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... |