#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 500003;
int n;
pair<ll, ll> val[MAXN];
ll pref_b[MAXN];
ll max_pref_b[MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; n >= i; i++) {
cin >> val[i].first >> val[i].second;
}
sort(val + 1, val + n + 1);
for (int i = 1; n >= i; i++) {
pref_b[i] = pref_b[i - 1] + val[i].second;
}
for (int i = 1; n >= i; i++) {
max_pref_b[i] = max(max_pref_b[i - 1], val[i].first - pref_b[i - 1]);
}
ll wynik= 0;
for (int i = 1; n >= i; i++) {
wynik = max(wynik, pref_b[i] - val[i].first + max_pref_b[i]);
}
cout << wynik;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |