Submission #898915

#TimeUsernameProblemLanguageResultExecution timeMemory
898915LinkedArrayAdvertisement 2 (JOI23_ho_t2)C++17
100 / 100
134 ms18000 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...