Submission #875598

#TimeUsernameProblemLanguageResultExecution timeMemory
875598hmm789Advertisement 2 (JOI23_ho_t2)C++14
100 / 100
133 ms29704 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF 1000000000000000000 #define MOD 998244353 int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, ans = 1, idx = 0; cin >> n; int x[n], e[n], b[n]; pair<int, int> a[n]; for(int i = 0; i < n; i++) { cin >> x[i] >> e[i]; a[i] = {x[i]+e[i], i}; } sort(a, a+n); for(int i = 0; i < n; i++) b[i] = INF; for(int i = 0; i < n; i++) { b[idx] = min(b[idx], x[a[i].second]-e[a[i].second]); if(i == n-1 || a[i].first != a[i+1].first) idx++; } for(int i = idx-2; i >= 0; i--) b[i] = min(b[i], b[i+1]); for(int i = 0; i < idx-1; i++) if(b[i] < b[i+1]) ans++; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...