Submission #1135456

#TimeUsernameProblemLanguageResultExecution timeMemory
1135456nuutsnoyntonArt Exhibition (JOI18_art)C++20
0 / 100
0 ms320 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll N = 5e5 + 2; pair < ll, ll > P[N]; int main() { ll n, m, r, x, y, i, j, ans, t, mx; cin >> n; for (i = 1; i <= n; i ++) { cin >> P[i].first >> P[i].second; } sort ( P + 1, P + n + 1); ll pre[n+ 2]; ll a[n +2 ], b[n + 2]; pre[0] = 0; for (i = 1; i <= n; i ++) { pre[i] = pre[i - 1] +P[i].second; } for (i =1; i <= n; i ++) { a[i] = pre[i] - P[i].first ; b[i] = P[i].first - pre[i - 1]; } ans =0; mx = b[1]; for (i = 2; i <= n; i ++) { ans = max(ans, mx + a[i]); mx = max(mx, b[i]); } 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...