제출 #857264

#제출 시각아이디문제언어결과실행 시간메모리
857264annabeth9680Art Exhibition (JOI18_art)C++17
100 / 100
188 ms24904 KiB
#include <bits/stdc++.h> #define int long long #define f first #define s second using namespace std; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; vector<pair<int,int>> arr(N); for(int i = 0;i<N;++i) cin >> arr[i].f >> arr[i].s; sort(arr.begin(),arr.end()); vector<int> pref(N); pref[0] = arr[0].s; for(int i = 1;i<N;++i) pref[i] = pref[i-1]+arr[i].s; int ans = -1, mincur = -arr[0].f; for(int i = 1;i<N;++i){ int cur = pref[i-1]-arr[i].f; mincur = min(mincur,cur); ans = max(ans,cur+arr[i].s-mincur); //cout << ans << " " << mincur << " " << cur << "\n"; } 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...