제출 #776215

#제출 시각아이디문제언어결과실행 시간메모리
776215khoquennguoiminhthuongArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 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; ans=p[1].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); //cout<<ans<<'\n'; minn=min(minn,tong-p[i].first); tong+=p[i].second; } cout<<ans; 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...