結果

問題 No.1037 exhausted
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-05-13 19:04:01
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,331 bytes
コンパイル時間 2,821 ms
コンパイル使用メモリ 150,040 KB
実行使用メモリ 34,712 KB
最終ジャッジ日時 2023-10-12 17:02:13
合計ジャッジ時間 3,817 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
4,348 KB
testcase_03 RE -
testcase_04 WA -
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 RE -
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 2 ms
4,356 KB
testcase_10 RE -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 38 ms
34,172 KB
testcase_21 AC 39 ms
34,584 KB
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.13 19:03:41
**/
#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

struct Hoge {
    int x, v, w;
    Hoge(int x = 0, int v = 0, int w = 0) : x(x), v(v), w(w) {}
};

int main() {
    int n, v, l;
    cin >> n >> v >> l;
    constexpr long long LLINF = 1e18 + 1;
    vector< vector< ll > > dp(n + 1, vector< ll >(v + 1, LLINF));
    dp[0][v] = 0;
    vector< Hoge > hg(n + 1);
    hg[0] = Hoge(0, 0, 0);
    for (int i = 0; i < n; i++) {
        cin >> hg[i + 1].x >> hg[i + 1].v >> hg[i + 1].w;
        for (int j = 0; j <= v; j++) {
            if (j - (hg[i + 1].v - hg[i].v) >= 0) {
                dp[i + 1][min(v, j - (hg[i + 1].x - hg[i].x) + hg[i + 1].v)] = min(dp[i + 1][min(v, j - (hg[i + 1].x - hg[i].x) + hg[i + 1].v)], dp[i][j] + hg[i + 1].w);  // 補給する
                dp[i + 1][j - (hg[i + 1].x - hg[i].x)] = min(dp[i + 1][j - (hg[i + 1].x - hg[i].x)], dp[i][j]);                                                            // 補給しない
            }
        }
    }
    ll ans = LLINF;
    for (int i = l - hg[n].x; i <= v; i++) {
        ans = min(dp[n][i], ans);
    }
    // cout << dp << endl;
    if (ans == LLINF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

0