#include <bits/stdc++.h>
#define ll long long
#define pii pair <ll, ll>
#define st first
#define nd second
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, m, n) for (ll i = (m); i >= (n); i --)
using namespace std;
const long long N = 2e5 + 5;
ll n, f[N];
pii a[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
rep(i, 1, n) cin >> a[i].st >> a[i].nd;
sort(a + 1, a + 1 + n);
ll ans = 0;
ll mi = -a[1].st;
rep(i, 1, n) {
f[i] = f[i - 1] + a[i].nd;
ll p = f[i] - a[i].st;
ans = max(ans, p - mi);
mi = min(mi, f[i] - a[i + 1].st);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |