結果

問題 No.1037 exhausted
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2020-05-13 18:52:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,162 bytes
コンパイル時間 1,323 ms
コンパイル使用メモリ 150,172 KB
実行使用メモリ 34,764 KB
最終ジャッジ日時 2023-10-12 17:01:58
合計ジャッジ時間 3,384 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/**
 *   @FileName	f.cpp
 *   @Author	kanpurin
 *   @Created	2020.05.13 18:51:39
**/
#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 (hg[i + 1].x-hg[i].x > j) continue;
            dp[i + 1][j-(hg[i + 1].x-hg[i].x)+hg[i + 1].v] = min(dp[i + 1][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