/**
* Martin Leshko ([email protected])
*/
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define sz(a) (int)a.size()
const int N = 300001;
int main() {
int n;
cin >> n;
vector< pair<int, int> > a(n);
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
a[i] = {x, y};
}
sort(a.begin(), a.end());
long long prefix = 0, mn = 0x3f3f3f3f, ans = -0x3f3f3f3f;
for (int i = 0; i < n; i++) {
prefix += a[i].second;
mn = min(mn, prefix - a[i].second - a[i].first);
ans = max(ans, prefix - a[i].first - mn);
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |