Submission #776314

#TimeUsernameProblemLanguageResultExecution timeMemory
776314khoquennguoiminhthuongArt Exhibition (JOI18_art)C++17
100 / 100
146 ms8304 KiB
#include <bits/stdc++.h> using namespace std; pair<long long,long long>p[500005]; int n; long long ans=-1e18; int main() {ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); 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...