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<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#define int long long
using namespace std;
bool cmp(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::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<pair<int, int> >v(n);
int a, b;
for (int i = 0 ; i < n ; i++) {
cin >> a >> b;
v[i] = {a-b, a+b};
//cout << a-b << " " << a+b << "\n";
}
sort(v.begin(), v.end(), cmp);
int ans = 1, right = v[0].second;
for (int i = 1 ; i < n ; i++) {
if (v[i].second <= right) continue;
ans++;
right = v[i].second;
}
cout << ans << "\n";
}
# | 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... |