Submission #897360

#TimeUsernameProblemLanguageResultExecution timeMemory
897360boxArt Exhibition (JOI18_art)C++17
100 / 100
169 ms20820 KiB
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n; cin >> n;
    vector<pair<long long, int>> a(n);
    for (auto &[x, y] : a) cin >> x >> y;
    sort(a.begin(), a.end());
    long long ans = 0, pre = 1e18, cur = 0;
    for (auto [x, y] : a) {
        pre = min(pre, cur - x);
        ans = max(ans, cur - x + y - pre), cur += y;
    }
    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...