Submission #747451

#TimeUsernameProblemLanguageResultExecution timeMemory
747451ereringArt Exhibition (JOI18_art)C++17
100 / 100
175 ms16060 KiB
#include <bits/stdc++.h> using namespace std; #define endl '\n' #define mod 1000000007 #define ll long long #define inf 1000000009 int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); ll a; cin>>a; pair<ll,ll> p[a+1]; p[0].first=-1; p[0].second=-1; for(int i=1;i<=a;i++){ cin>>p[i].first; cin>>p[i].second; } sort(p,p+a+1); ll pref[a+1],prefmn[a+1]; pref[0]=0; prefmn[0]=1e9; for(int i=1;i<=a;i++){ pref[i]=p[i].second+pref[i-1]; prefmn[i]=min(prefmn[i-1],p[i].first*-1+pref[i-1]); } ll mx=0; for(int i=1;i<=a;i++){ mx=max(mx,pref[i]-p[i].first-prefmn[i]); } cout<<mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...