제출 #577880

#제출 시각아이디문제언어결과실행 시간메모리
577880Trisanu_DasArt Exhibition (JOI18_art)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<pair<int, int>> a(n); for (auto p : a) cin >> p.first >> p.second; sort(a.begin(), a.end()); int pref[n + 1]; for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + a[i].second; vector diff(pref + 1, pref + n + 1); for (int i = 0; i < n; i++) diff[i] -= a[i].first; int ans = 0, tmp = INT_MIN / 2; for (int i = n - 1; i > -1; i--) { tmp = max(tmp, diff[i]); ans = max(ans, tmp + a[i].first - pref[i]); } 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...