제출 #1033890

#제출 시각아이디문제언어결과실행 시간메모리
1033890sp69tArt Exhibition (JOI18_art)C++14
100 / 100
140 ms12368 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<ll, ll>> a(n); for (auto &p : a) cin >> p.first >> p.second; sort(a.begin(), a.end()); vector<ll> p(n + 1, 0); for (int i = 0; i < n; ++i) p[i + 1] = p[i] + a[i].second; ll mx = 0, res = 0; for (int i = 0; i < n; ++i) { mx = max(mx, -p[i] + a[i].first); res = max(res, p[i + 1] - a[i].first + mx); } cout << res << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...