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;
#define int long long
#define f first
#define s second
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (int i = 0;i < n;i++) {
int x, y;
cin >> x >> y;
a[i] = {x - y, x + y};
}
sort(a.begin(), a.end(), [&](pair<int, int> x, pair<int, int> y) {
if (x.f == y.f)
return x.s > y.s;
return x.f < y.f;
});
int ans = 0, bst = -1;
for (int i = 0;i < n;i++) {
if (bst < a[i].s) {
bst = a[i].s;
++ans;
}
}
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... |