#include<bits/stdc++.h>
#define int long long
using namespace std;
pair<int, int> arr[500001];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> arr[i].first >> arr[i].second;
sort(arr, arr + n + 1);
for (int i = 1; i < n; i++)
arr[i].second += arr[i - 1].second;
int ans = 0;
for (int i = 1; i <= n; i++)
for (int j = i + 1; j <= n; j++)
ans = max(ans, arr[j].second - arr[i - 1].second - arr[j].first + arr[i].first);
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |