제출 #766236

#제출 시각아이디문제언어결과실행 시간메모리
766236PekibanArt Exhibition (JOI18_art)C++17
0 / 100
0 ms212 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, long long> a[n+1]; for (int i = 1; i <= n; ++i) { cin >> a[i].first >> a[i].second; } sort(a, a+n+1); 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 = a[1].first, ans = 0; 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...