#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
ll n;cin>>n;
ll ans=LLONG_MIN;pll x[2*n+1];x[0]={0,0};
for(int i=1;i<=n;i++)cin>>x[i].f>>x[i].s;
sort(x,x+n+1);for(int i=1;i<=n;i++)x[i].s=x[i-1].s+x[i].s;
ll mx=x[n].s-x[n].f;
for(int l=n;l>=1;l--){
ans=max(ans,mx-x[l-1].s+x[l].f);
mx=max(mx,x[l].s-x[l].f);
}cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |