Submission #367603

#TimeUsernameProblemLanguageResultExecution timeMemory
367603Runtime_error_Art Exhibition (JOI18_art)C++14
100 / 100
613 ms24940 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; const int inf = 5e5+9; ll n,pre[inf],ans,mn; pair<ll,ll> a[inf]; int main(){ cin>>n; for(int i=1;i<=n;i++) cin>>a[i].first>>a[i].second; sort(a+1,a+1+n); for(int i=1;i<=n;i++){ pre[i] = pre[i-1] + a[i].second; mn = min(mn,pre[i-1] - a[i].first); ans = max(ans, pre[i] - a[i].first - mn); } 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...