#include<bits/stdc++.h>
using namespace std;
const int N = (int)5e5+7;
const long long INF = (long long)1e18+7;
int n;
pair<long long, long long> a[N];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
for(int i = 1; i <= n; ++i) {
cin >> a[i].first >> a[i].second;
}
sort(a+1, a+1+n);
long long ans = 0, cur = 0, mn = 0;
for(int i = 1; i <= n; ++i) {
cur += a[i].second;
ans = max(ans, cur-a[i].first-mn);
mn = min(mn, (cur-a[i].second)-a[i].first);
}
cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |