#include <bits/stdc++.h>
using namespace std ;
const int N = 1e5 + 7 ;
int n ;
vector<pair<long long , long long > > v ;
long long ans ;
long long suf[N];
int main(){
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
//freopen("in.in" , "r" , stdin) ;
cin>>n ;
for(int i = 0 ; i < n;i++){
long long a ,b ;
cin>>a>>b ;
v.push_back({a , b}) ;
}
sort(v.begin() , v.end()) ;
suf[n-1] = v[n-1].second ;
for(int i = n-2 ; i>=0 ; i--){
suf[i] = suf[i+1] + v[i].second ;
}
priority_queue<long long > q ;
for(int i =n-1 ; i>=0 ;i--){
q.push( -suf[i+1] - v[i].first ) ;
ans = max(ans , q.top() + v[i].first + suf[i]) ;
}
cout<<ans;
return 0 ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |