이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
// @JASPER'S BOILERPLATE
using namespace std;
using ll = long long;
#ifdef JASPER
#include "debug.h"
#else
#define debug(...) 166
#endif
const int N = 5e3 + 5;
int n;
int x[N], g[N], e[N];
ll dp[N], fe[N], fg[N];
signed main() {
cin.tie(0) -> sync_with_stdio(0);
cin >> n;
for (int i = 1; i <= n; ++i) cin >> x[i] >> g[i] >> e[i];
for (int i = 1; i <= n; ++i) {
fg[i] = fg[i - 1] + g[i];
fe[i] = fe[i - 1] + e[i];
}
for (int i = 1; i <= n; ++i) dp[i] = g[i];
for (int i = 1; i <= n; ++i) {
for (int j = 1; j < i; ++j) {
ll req = (x[i] - x[j]);
ll have = (fe[i] - fe[j - 1]);
if (have >= req)
dp[i] = max(dp[i], dp[j] + 1LL * (fg[i] - fg[j]));
}
}
// for (int i = 1; i <= n; ++i) {
// debug(i, dp[i]);
// }
cout << *max_element(dp + 1, dp + 1 + n) << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |