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;
int main() {
int n; cin >> n;
vector<pair<int, int>> arr(n);
for (int i = 0; i < n; ++i) cin >> arr[i].second >> arr[i].first;
sort(arr.begin(), arr.end());
reverse(arr.begin(), arr.end());
set<pair<int, int>> given;
given.insert({0, 0});
given.insert({1000000007, 0});
int ans = 0;
for (pair<int, int> p : arr) {
int x = p.second, e = p.first;
pair<int, int> r = *given.upper_bound({x, e}), l = *--given.upper_bound({x, e});
if (abs(r.first - x) <= r.second - e || abs(l.first - x) <= l.second - e) continue;
++ans;
given.insert({x, e});
}
cout << ans << '\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... |