제출 #699613

#제출 시각아이디문제언어결과실행 시간메모리
699613Sandarach151Art Exhibition (JOI18_art)C++17
100 / 100
184 ms20928 KiB
#include <bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; pair<long long, long long> refarr[n]; for(int i=0; i<n; i++){ cin >> refarr[i].first >> refarr[i].second; } sort(refarr, refarr+n); for(int i=1; i<n; i++){ refarr[i].second+=refarr[i-1].second; } pair<long long, long long> arr[n]; arr[0].first=refarr[0].first; arr[0].second=refarr[0].second-refarr[0].first; for(int i=1; i<n; i++){ arr[i].first=refarr[i].first-refarr[i-1].second; arr[i].second=refarr[i].second-refarr[i].first; } long long maxfirst = arr[0].first; long long finans = maxfirst+arr[0].second; for(int i=1; i<n; i++){ maxfirst=max(maxfirst, arr[i].first); finans=max(finans, arr[i].second+maxfirst); } cout << max((long long) 0, finans) << '\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...