#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define x first
#define y second
pair<ll, ll> A[500005];
ll S[500005];
ll N;
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N;
for(int i = 1; i <= N; i++){
cin >> A[i].x >> A[i].y;
}
sort(A + 1, A + N + 1);
for(int i = 1; i <= N; i++){
S[i] = S[i - 1] + A[i].y;
}
ll ans = 0;
for(int i = 1; i <= N; i++){
for(int j = i + 1; j <= N; j++){
ans = max(ans, S[j] - S[i - 1] - A[j].x + A[i].x);
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |