제출 #927956

#제출 시각아이디문제언어결과실행 시간메모리
927956takeonickyArt Exhibition (JOI18_art)C++14
100 / 100
377 ms24984 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; pair<long long, long long> arr[n]; for(int i=0; i<n; i++){ cin>>arr[i].first>>arr[i].second; } sort(arr, arr+n); long long pref[n]; pref[0] = arr[0].second; for(int i=1; i<n; i++){ pref[i] = pref[i-1] + arr[i].second; } long long ans = 0; long long mn = -arr[0].first; for(int i=0; i<n; i++){ if(i != 0) mn = min(mn, pref[i-1] - arr[i].first); ans = max(ans, (pref[i]-arr[i].first)-mn); } cout<<ans<<endl; 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...