Submission #1180281

#TimeUsernameProblemLanguageResultExecution timeMemory
1180281miniobArt Exhibition (JOI18_art)C++20
100 / 100
113 ms12252 KiB
#include <bits/stdc++.h> using namespace std; long long pref[500007]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector<pair<long long, long long>> prace; prace.push_back({0, 0}); long long n, odp = 0, maxx = LLONG_MIN; cin >> n; for(int i = 0; i < n; i++) { long long x, y; cin >> x >> y; prace.push_back({x, y}); } sort(prace.begin(), prace.end()); for(int i = 1; i <= n; i++) { pref[i] = pref[i - 1] + prace[i].second; } for(int i = 1; i <= n; i++) { maxx = max(maxx, prace[i].first - pref[i - 1]); odp = max(odp, maxx + pref[i] - prace[i].first); } cout << odp << 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...