#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<stack>
#include<cmath>
#define Rint register int
#define ll long long
using namespace std;
int n;
struct node{
int l,v;
}a[500005];
bool cmp(node x,node y){
return x.l<y.l;
}
int presum[500005];
int temp[500005];
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].l>>a[i].v;
}
sort(a+1,a+1+n,cmp);
int maxx1=-0x7fffffff,minn=0x7fffffff,ans=0;
for(int i=1;i<=n;i++){
presum[i]=presum[i-1]+a[i].v;
}
for(int i=1;i<=n;i++){
maxx1=presum[i]-a[i].l;
ans=max(ans,maxx1-minn);
minn=min(minn,presum[i-1]-a[i].l);
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |