Submission #766208

#TimeUsernameProblemLanguageResultExecution timeMemory
766208PekibanArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; pair<long long, long long> a[n+1]; a[0] = {-1e18, -1e9}; for (int i = 1; i <= n; ++i) { cin >> a[i].first >> a[i].second; } sort(a+1, a+n+1); long long ans = 0; long long pref[n+1]; pref[0] = 0; for (int i = 1; i <= n; ++i) pref[i] = pref[i-1]+a[i].second; long long s = 0; for (int i = 1; i <= n; ++i) { ans = max(ans, (pref[i]-a[i].first)+s); s = max(s, a[i].first-pref[i-1]); } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...