#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
using ll = long long;
int n;
vector<pair<ll, ll>> a;
int main(){
cin >> n;
for(int i = 0; i < n; i++){
int x, y;
cin >> x >> y;
a.push_back({x, y});
}
a.push_back({0, 0});
sort(a.begin(), a.end());
ll best = 0, cur = 0;
for(int i = 0; i < n; i++){
cur += a[i].ss;
cur = max(cur, a[i].ss + a[i].ff);
best = max(best, cur - a[i].ff);
}
cout << best;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
368 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |