#include <bits/stdc++.h>
int main() {
int n;
std :: cin >> n;
std :: vector<std::pair<long long, long long>> ab(n);
for (auto &[a, b] : ab) std :: cin >> a >> b;
std :: sort(ab.begin(), ab.end());
long long pmx = INT64_MIN, tot = 0LL, ans = INT64_MIN;
for (auto [a, b] : ab) {
pmx = std :: max(pmx, a - tot); tot += b;
ans = std :: max(ans, tot - a + pmx);
}
std :: cout << ans << "\n";
}
# | 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... |