#include<bits/stdc++.h>
using namespace std;
int n;
vector<long long> p;
vector<pair<long long, int>> a;
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++){
int y;
long long x;
cin >> x >> y;
a.push_back({x, y});
}
sort(a.begin(), a.end());
p.resize(n, 0ll);
for(int i = 0; i < n; i ++){
if(i > 0) p[i] = p[i - 1];
p[i] += a[i].second;
}
long long mx = 0ll;
for(int i = 0; i < n; i ++){
for(int j = i + 1; j < n; j ++){
long long sum = p[j];
if(i > 0) sum -= p[i - 1];
mx = max(mx, sum - (a[j].first - a[i].first));
}
}
cout << mx << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |