#include<iostream>
#include<memory.h>
#include<utility>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long lld;
lld n, s[500001] = {0, }, a, b, tmp;
vector<pair<lld, lld>> art;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
art.push_back(pair<int, int>(0, 0));
for(int i = 0; i < n; i++) {
cin >> a >> b;
art.push_back(pair<int, int>(a, b));
}
sort(art.begin(), art.end());
for(int i = 1; i <= n; i++) {
s[i] = s[i-1] + get<1>(art[i]);
}
lld tmp = 0;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
tmp = max(tmp, s[j] - s[i-1] - get<0>(art[j]) + get<0>(art[i]));
}
}
cout << tmp << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |