제출 #1124128

#제출 시각아이디문제언어결과실행 시간메모리
1124128votranngocvyArt Exhibition (JOI18_art)C++20
100 / 100
146 ms12156 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define fi first #define se second const int N = 5e5 + 5; pii a[N]; int pre[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(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); for (int i = 1; i <= n; i++) pre[i] = pre[i - 1] + a[i].se; int mini = -a[1].fi,ans = 0; for (int i = 1; i <= n; i++) { ans = max(ans,pre[i] - a[i].fi - mini); mini = min(mini,pre[i] - a[i + 1].fi); } cout << ans << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...