제출 #1135458

#제출 시각아이디문제언어결과실행 시간메모리
1135458nuutsnoyntonArt Exhibition (JOI18_art)C++20
100 / 100
357 ms19912 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const ll N = 5e5 + 2; pair < ll, ll > P[N]; int main() { ll n, m, r, x, y, i, j, mn, ans, t, mx; cin >> n; for (i = 1; i <= n; i ++) { cin >> P[i].first >> P[i].second; } sort ( P + 1, P + n + 1); ll pre[n+ 2]; ll a[n +2 ], b[n + 2]; pre[0] = 0; for (i = 1; i <= n; i ++) { pre[i] = pre[i - 1] +P[i].second; } for (i =1; i <= n; i ++) { a[i] = pre[i] - P[i].first ; b[i] = pre[i - 1] - P[i].first; } ans =0; mn = LONG_MAX; for (i = 1; i <= n; i ++) { mn = min(mn, b[i]); ans = max(ans, a[i] - mn); } 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...