Submission #47127

#TimeUsernameProblemLanguageResultExecution timeMemory
47127dqhungdlArt Exhibition (JOI18_art)C++17
100 / 100
773 ms231104 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int64_t,int64_t> ii; int64_t n,s[500005]; ii a[500005]; int main() { cin>>n; for(int64_t i=1;i<=n;i++) cin>>a[i].first>>a[i].second; sort(a+1,a+n+1); for(int64_t i=1;i<=n;i++) s[i]=s[i-1]+a[i].second; int64_t maxn=-1e18,res=-1e18; for(int64_t i=1;i<=n;i++) { maxn=max(maxn,a[i].first-s[i-1]); res=max(res,s[i]-a[i].first+maxn); } cout<<res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...