#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 6e5 + 1;
int pre[N],n;
pair<int,int> a[N];
signed main()
{
cin >> n;
for(int i = 1; i <= n; i ++)
{
cin >> a[i].first >> a[i].second;
}
sort(a+1,a+n+1);
for(int i = 1; i <= n; i ++)
{
pre[i] = pre[i-1] + a[i].second;
}
int minn = 1e18,ans = -1e18;
for(int i = 1; i <= n; i++)
{
ans = max(ans,pre[i] - a[i].first - minn);
minn = min(pre[i-1]-a[i].first,minn);
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |