Submission #818468

#TimeUsernameProblemLanguageResultExecution timeMemory
818468null_aweAdvertisement 2 (JOI23_ho_t2)C++14
100 / 100
444 ms34636 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...