제출 #650677

#제출 시각아이디문제언어결과실행 시간메모리
650677ShinArt Exhibition (JOI18_art)C++14
100 / 100
211 ms24760 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair using namespace std; template <class X, class Y> bool minimize(X &a, Y b) { if (a > b) return a = b, true; return false; } template <class X, class Y> bool maximize(X &a, Y b) { if (a < b) return a = b, true; return false; } const int N = 5e5 + 7; pair<long long, int> a[N]; long long pref[N]; signed main() { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for (int i = 1; i <= n; i ++) { cin >> a[i].fi >> a[i].se; } sort(a + 1, a + n + 1); long long res = 0, mx = 0; for (int i = 1; i <= n; i ++) { pref[i] = pref[i - 1] + a[i].se; maximize(mx, -pref[i - 1] + a[i].fi); maximize(res, pref[i] - a[i].fi + mx); } cout << res; 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...