제출 #372346

#제출 시각아이디문제언어결과실행 시간메모리
372346mariowongArt Exhibition (JOI18_art)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; long long n,l; long long ans,b[500005],mx[500005],ps[500005]; pair<long long,long long> a[500005]; int main(){ ios::sync_with_stdio(false); 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++){ ps[i]=ps[i-1]+a[i].second; b[i]=ps[i]-a[i].first; } for (int i=n;i>=1;i--){ mx[i]=max(mx[i+1],b[i]); } ans=-1e18; for (int i=1;i<=n;i++){ ans=max(ans,mx[i]+a[i].first-ps[i-1]); } 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...