이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
const long long inf = 1e18;
int n; cin >> n;
set<array<long long, 2>> st;
auto qry = [&](long long x) {
auto it = st.upper_bound({x + 1, -inf});
return it == st.begin() ? inf : (*prev(it))[1];
};
auto add = [&](long long x, long long y) {
if (qry(x) <= y) {
return;
}
auto it = st.insert({x, y}).first;
for (++it; it != st.end(); it = st.erase(it)) {
if ((*it)[1] < y) {
break;
}
}
};
long long x = 0, y = 0, res = 0;
while (n--) {
int p, g, d; cin >> p >> g >> d;
add(y - p, x);
x += g, y += d;
res = max(res, x - qry(y - p));
}
cout << res;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |