Submission #853402

#TimeUsernameProblemLanguageResultExecution timeMemory
853402parsadox2Art Exhibition (JOI18_art)C++14
100 / 100
149 ms20088 KiB
#include <bits/stdc++.h> #define int long long using namespace std; const int N = 5e5 + 10; int n , a[N] , b[N] , ps[N]; pair<int , int> ar[N]; signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for(int i = 0 ; i < n ; i++) cin >> ar[i].first >> ar[i].second; sort(ar , ar + n); for(int i = 0 ; i < n ; i++) { a[i] = ar[i].first; b[i] = ar[i].second; ps[i] = b[i] + (i == 0 ? 0 : ps[i - 1]); } int ans = 0; int mx = -1e15; for(int i = n - 1 ; i > -1 ; i--) { mx = max(mx , ps[i] - a[i]); ans = max(ans , mx - (i == 0 ? 0 : ps[i - 1]) + a[i]); } 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...