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;
using ll = long long;
#define pb push_back
#define int ll
const int MAX_N = 5e5;
pair<int, int> ans[MAX_N + 5];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, i, x, e, cnt, min_val;
cin >> n;
for (i = 0; i < n; i++) {
cin >> x >> e;
ans[i] = {x, e};
}
sort(ans, ans + n, [](pair<int, int> a, pair<int, int> b) {
pair<int, int> v1 = {a.first - a.second, -a.first - a.second},
v2 = {b.first - b.second, -b.first - b.second};
return (v1.first < v2.first || (v1.first == v2.first && v1.second < v2.second));
});
cnt = min_val = 0;
for (i = 0; i < n; i++) {
int val = -ans[i].first - ans[i].second;
if (val < min_val) {
min_val = val;
cnt++;
}
}
cout << cnt;
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... |