Submission #712049

#TimeUsernameProblemLanguageResultExecution timeMemory
712049happypotatoArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int n; cin >> n; pair<ll, ll> a[n]; for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(a, a + n); ll mini = -a[0].first, maxi = -1e18; ll ans = 0; ll ps = 0; ll cur; for (int i = 0; i < n; i++) { ps += a[i].second; cur = ps - a[i].first; if (cur > maxi) { maxi = cur; ans = max(ans, maxi - mini); } if (i + 1 < n) { cur = ps - a[i + 1].first; if (cur < mini) mini = cur; } } cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...