제출 #710661

#제출 시각아이디문제언어결과실행 시간메모리
710661yellowtoadArt 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; maxx[n+1] = -1e18; for (int i = n; i >= 1; i--) maxx[i] = max(maxx[i+1],ps[i]-a[i].f), cout << maxx[i] << endl; for (int i = 1; i <= n; i++) ans = max(ans,maxx[i]+a[i].f-ps[i-1]); cout << ans << endl; } /* 2 1000000000000000 1000000000 1000000000000000 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...