This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
author: lunchbox
problem link: https://oj.uz/problem/view/JOI18_art
*/
#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) {
ans = max(ans, cur - x + y - pre);
pre = min(pre, cur - x), cur += y;
}
cout << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |