Submission #537890

#TimeUsernameProblemLanguageResultExecution timeMemory
537890daisyArt Exhibition (JOI18_art)C++17
100 / 100
202 ms12352 KiB
#include<iostream> #include<algorithm> #define endl '\n' using namespace std; long long n,pref=0,s,maxr=0,mi=0,ma=0; pair<long long,long long> p[500005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second; sort(p,p+n); for(int i=0;i<n;i++) { mi=max(mi,p[i].first-pref); pref+=p[i].second; maxr=max(maxr,mi+pref-p[i].first); } cout<<maxr<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...