#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct PAINT
{
ll sz;
ll val;
bool operator < (const PAINT &d2) const{
return sz < d2.sz;
}
};
const int mxN = 5e5 + 5;
int n;
PAINT p[mxN];
int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin>> n;
for(int i=1;i<=n;i++) cin>> p[i].sz >> p[i].val;
sort(p+1 , p+1+n);
// for(int i=1;i<=n;i++) printf("%lld %lld\n" , p[i].sz , p[i].val);
ll ans = p[1].val;
ll reduce = -p[1].sz;
ll sum = p[1].val;
for(int i=2;i<=n;i++){
reduce = min(reduce , sum-p[i-1].sz);
sum += p[i].val;
ll res = (sum - p[i].sz) - reduce;
ans = max(ans , res);
}
cout<< ans;
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 |
- |