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>
#define int long long
using namespace std;
bool comp(pair<int,int> a, pair<int,int> b){
if(a.first==b.first) return a.second>b.second;
return a.first<b.first;
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int N; cin >> N;
vector<pair<int,int>> a(N);
for (int i = 0; i < N; i++)
{
int x,e; cin >> x >> e;
a[i]={x-e, x+e};
}
sort(a.begin(), a.end(), comp);
int sum=1;
int r=a[0].second;
for (int i = 1; i < N; i++)
{
if(r<a[i].second) {
sum++;
}
r=max(a[i].second, r);
}
cout << sum << "\n";
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... |