#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
int main() {
int n;
cin >> n;
pair<long long, long long> a[n];long long pref[n+1]; pref[0]=0;
for(int i=0; i<n; i++){
cin >> a[i].f >> a[i].s;
}
sort(a, a+n);
for(int i=0; i<n; i++){
pref[i+1]=pref[i]+a[i].s;
}
long long mx=-INT64_MAX;
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
mx=max(mx, pref[j+1]-pref[i]-a[j].f+a[i].f);
}
}
cout << mx;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |