#include <iostream>
#include <bits/stdc++.h>
#define rWAn ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define ll long long
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
using namespace std;
int main()
{
rWAn
int n;
cin>>n;
vector<pair<ll,ll> >v;
for(int i=0;i<n;i++){
ll x,y;
cin>>x>>y;
v.push_back(make_pair(x,y));
}
sort(all(v));
ll s=0,mx=-1,mn=1e15;
ll maxi=-1;
for(auto i:v){
s+=i.second;
mx=max(mx,i.first);
mn=min(mn,i.first);
maxi=max(maxi,s-(mx-mn));
}
cout<<maxi<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |