제출 #916480

#제출 시각아이디문제언어결과실행 시간메모리
916480GrandTiger1729Advertisement 2 (JOI23_ho_t2)C++17
100 / 100
602 ms37520 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } multiset<pair<int, int>> st(a.begin(), a.end()); sort(a.begin(), a.end(), [&](auto x, auto y) { return x.second > y.second; }); int ans = 0; for (int i = 0; i < n; i++) { if (st.find(a[i]) == st.end()) { continue; } ans++; auto it = st.find(a[i]); while (it != st.begin()) { auto it2 = it; it2--; if (abs(a[i].first - it2->first) <= a[i].second - it2->second) { st.erase(it2); } else { break; } } while (it != st.end()) { auto it2 = it; it++; if (abs(a[i].first - it2->first) <= a[i].second - it2->second) { st.erase(it2); } else { break; } } } 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...