#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn = 500100;
vector<pair<ll,ll> > v;
ll pref[maxn], n;
int main() {
cin>>n;
ll a, b;
for(int i=1;i<=n;i++) {
cin>>a>>b;
v.pb({a, b});
} sort(v.begin(), v.end());
ll maxv = v[0].first;
ll result = 0LL;
for(int i=1;i<=n;i++) {
pref[i] = pref[i-1] + v[i-1].second;
result = max(result, pref[i] - v[i-1].first + maxv);
maxv = max(maxv, v[i-1].first - pref[i-1]);
}
cout<<result<<"\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |