제출 #710660

#제출 시각아이디문제언어결과실행 시간메모리
710660yellowtoadArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <iostream> #include <algorithm> #define f first #define s second using namespace std; long long n, ans, ps[500010], maxx[500010]; pair<long long, long long> a[500010]; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i].f >> a[i].s; sort(a+1,a+n+1); for (int i = 1; i <= n; i++) ps[i] = ps[i-1]+a[i].s; for (int i = n; i >= 1; i--) maxx[i] = max(maxx[i+1],ps[i]-a[i].f); for (int i = 1; i <= n; i++) ans = max(ans,maxx[i]+a[i].f-ps[i-1]); cout << ans << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...