#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
int n;
cin >> n;
pair<ll, ll> a[n];
for (int i = 0; i < n; i++) {
cin >> a[i].first >> a[i].second;
}
sort(a, a + n);
ll mini = -a[0].first, maxi = -1e18;
ll ans = 0;
ll ps = 0;
ll cur;
for (int i = 0; i < n; i++) {
ps += a[i].second;
cur = ps - a[i].first;
if (cur > maxi) {
maxi = cur;
ans = max(ans, maxi - mini);
}
if (i + 1 < n) {
cur = ps - a[i + 1].first;
if (cur < mini) mini = cur;
}
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |