제출 #766200

#제출 시각아이디문제언어결과실행 시간메모리
766200PekibanArt Exhibition (JOI18_art)C++17
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; pair<long long, int> a[n+1]; a[0] = {-1e18, -1e9}; for (int i = 1; i <= n; ++i) { cin >> a[i].first >> a[i].second; } sort(a+1, a+n+1); long long ans = 0; long long pref[n+1]; pref[0] = 0; for (int i = 1; i <= n; ++i) pref[i] = pref[i-1]+a[i].second; long long s = -1e18; for (int i = 1; i <= n; ++i) { ans = max(ans, (pref[i]-a[i].first)+s); s = max(s, a[i].first-pref[i-1]); } 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...