Submission #947988

#TimeUsernameProblemLanguageResultExecution timeMemory
947988PM1Art Exhibition (JOI18_art)C++17
100 / 100
492 ms44608 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define fr first #define sc second const int mxn=5e5+5; int n; pair<ll ,ll >a[mxn]; set<ll >s; ll lazy=0; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i].fr>>a[i].sc; } sort(a+1,a+n+1); s.insert(a[1].sc); ll ans=a[1].sc; for(int i=2;i<=n;i++){ lazy+=a[i].sc; lazy-=a[i].fr-a[i-1].fr; s.insert(a[i].sc-lazy); ll x=*s.rbegin(); ans=max(ans,x+lazy); } cout<<ans; 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...