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