#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n; cin >> n;
vector<pair<ll,ll>> paint;
for(int i=0;i<n;i++){
ll a,b; cin >> a >> b;
paint.push_back({a,b});
}
sort(paint.begin(),paint.end());
vector<ll> prefsum(n+1,0);
for(int i=0;i<n;i++)prefsum[i+1]=prefsum[i]+paint[i].second;
ll ans=0;
ll m=0;
for(int i=0;i<n;i++){
ans=max(ans,prefsum[i+1]-paint[i].first+m);
m=max(m,paint[i].first-prefsum[i]);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |