Submission #776312

#TimeUsernameProblemLanguageResultExecution timeMemory
776312khoquennguoiminhthuongArt Exhibition (JOI18_art)C++14
100 / 100
456 ms20872 KiB
#include <bits/stdc++.h> using namespace std; pair<long long,long long>p[500005]; int n; long long ans=-1e18; int main() { cin>>n; for(int i=1;i<=n;i++)cin>>p[i].first>>p[i].second; sort(p+1,p+n+1); long long tong=0; long long minn=0; for(int i=1;i<=n;i++)ans=max(ans,p[i].second); minn=min(minn,-p[1].first); tong+=p[1].second; for(int i=2;i<=n;i++) { ans=max(ans,tong+p[i].second-p[i].first-minn); minn=min(minn,tong-p[i].first); tong+=p[i].second; } cout<<ans<<'\n'; 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...