Submission #635522

#TimeUsernameProblemLanguageResultExecution timeMemory
635522Ronin13Art Exhibition (JOI18_art)C++14
100 / 100
538 ms24752 KiB
#include <bits/stdc++.h> #define ll long long #define f first #define s second #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back #define epb emplace_back #define ull unsigned ll using namespace std; int main(){ int n; cin >> n; pll a[n + 1]; for(int i= 1; i <= n; i++) cin >> a[i].f >> a[i].s; sort(a + 1, a + 1 + n); ll pref[n + 1]; pref[0] = 0; for(int i = 1; i <= n; i++) pref[i] = pref[i - 1] + a[i].s; ll mx = 0; ll ans = 0; for(int i = 1; i <= n; i++){ mx = max(mx, a[i].f - pref[i - 1]); ans = max(ans, pref[i] - a[i].f + mx); } cout << ans; 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...