Submission #392559

#TimeUsernameProblemLanguageResultExecution timeMemory
392559lukameladzeArt Exhibition (JOI18_art)C++14
100 / 100
562 ms18628 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; const int N=5e5+5; long long n,pr[N],ans,mn; pair <long long , long long> a[N]; int main() { cin>>n; for (int i=1; i<=n; i++) { cin>>a[i].f>>a[i].s; } sort(a+1, a+n+1); for (int i=1; i<=n; i++) { pr[i]=pr[i-1]+a[i].s; } ans=0; mn=-a[1].f; for (int i=1; i<=n; i++) { // cout<<i<<" "<<pr[i]-a[i].f<<" "<<mn<<endl; ans=max(ans, pr[i]-a[i].f-mn); mn=min(mn,pr[i]-a[i+1].f); } cout<<ans<<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...