#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;
const int N = 5e5+3;
int c[N], best[N], n, k;
pair <int,int> pic[N];
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>pic[i].fi>>pic[i].se;
}
sort(pic+1,pic+1+n);
c[1] = pic[1].se;
for(int i=2;i<=n;i++)
{
c[i] = pic[i].se - (pic[i].fi - pic[i-1].fi);
}
int ans = 0;
for(int i=1;i<=n;i++)
{
best[i] = max(best[i-1] + c[i], c[i]);
ans = max(ans, best[i]);
}
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |