답안 #916636

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
916636 2024-01-26T08:09:35 Z atom 금 캐기 (IZhO14_divide) C++17
17 / 100
1 ms 604 KB
#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];
int 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) {
            int req = (x[i] - x[j]);
            int have = (fe[i] - fe[j - 1]);
            if (have >= req) 
                dp[i] = max(dp[i], dp[j] + (fg[i] - fg[j]));
        }
    }
    // for (int i = 1; i <= n; ++i) {
    //     debug(i, dp[i]);
    // }
    cout << *max_element(dp + 1, dp + 1 + n) << "\n";
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Incorrect 1 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -