Submission #1313073

#TimeUsernameProblemLanguageResultExecution timeMemory
1313073AgageldiArt Exhibition (JOI18_art)C++20
100 / 100
129 ms15932 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define N 500005 #define f first #define s second int tc = 1, n, ans = LLONG_MIN, p[N], S[N]; pair <int,int> a[N]; int32_t main() { ios::sync_with_stdio(0);cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i].f >> a[i].s; } sort(a + 1, a + n + 1); for(int i = 1; i <= n; i++) { S[i] = a[i].s + S[i - 1]; p[i] = max(p[i - 1], a[i].f - S[i - 1]); ans = max(ans,S[i] - a[i].f + p[i]); } cout << ans << '\n'; 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...