Submission #1115610

#TimeUsernameProblemLanguageResultExecution timeMemory
1115610staszic_ojuzArt Exhibition (JOI18_art)C++17
100 / 100
141 ms24900 KiB
#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n; cin>>n; vector<pair<long long, long long>> vect(n); for (long long i=0;i<n;i++) cin>>vect[i].first>>vect[i].second; sort(vect.begin(), vect.end()); vector<long long> adds(n); adds[n-1]=vect[n-1].second; for (long long i=0;i<n-1;i++){ adds[i]=vect[i].second-vect[i+1].first+vect[i].first; } long long current=0, best=-1e15-1; for (long long i=n-1;i>=0;i--){ current+=adds[i]; current=max(current, vect[i].second); best=max(best, current); } cout<<best<<'\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...