#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
#define ll long long
const ll maxn=500001;
ll n,ans=0;
pair<ll,ll> art[maxn];
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>art[i].first>>art[i].second;
}
sort(art,art+n);
ll l=0,r=0,curans=0,prevans=0,su=0;
while(l<n){
if(r<n){
su+=art[r].second;
curans=su-(art[r].first-art[l].first);
}
if(curans>=prevans and r<n){
r++;
prevans=curans;
}else{
su-=art[l].second;
l++;
prevans=0;
}
ans=max(ans,curans);
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |