Submission #595258

#TimeUsernameProblemLanguageResultExecution timeMemory
595258zxcvbnmArt Exhibition (JOI18_art)C++14
100 / 100
203 ms20680 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<pair<ll, ll>> a(n); for(auto& i : a) { cin >> i.first >> i.second; } sort(a.begin(), a.end()); ll ans = 0; ll curr = 0; for(int i = 0; i < n; i++) { ans = max(ans, curr + a[i].second); if (i != n-1) { curr += a[i].second - (a[i+1].first - a[i].first); curr = max(curr, 0LL); } } 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...