#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <stack>
#include <unordered_map>
using namespace std;
typedef long long ll;
struct dzielo {
ll s;
ll v;
};
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n; cin >> n;
vector<dzielo> arts(n);
for(ll i = 0; i < n; i++) {
ll s, v; cin >> s >> v;
arts[i].s = s; arts[i].v = v;
}
sort(arts.begin(), arts.end(), [](dzielo a, dzielo b) {return a.s < b.s;});
vector<ll> wn(n);
wn[0] = arts[0].v;
for(int i = 1; i < n; i++) {
wn[i] = arts[i].v + arts[i - 1].s - arts[i].s;
//cout << wn[i] << " ";
}
//cout << endl;
ll c = 0;
ll mx = 0;
for(int i = 0; i < n; i++) {
c += wn[i];
c = max((ll)0, c);
mx = max(mx, c);
}
cout << mx;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |