結果

問題 No.1037 exhausted
ユーザー tamatotamato
提出日時 2020-04-24 22:56:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 145 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 108,364 KB
最終ジャッジ日時 2024-04-23 04:04:00
合計ジャッジ時間 2,767 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,516 KB
testcase_01 AC 33 ms
53,748 KB
testcase_02 AC 33 ms
53,548 KB
testcase_03 AC 34 ms
52,340 KB
testcase_04 AC 33 ms
52,980 KB
testcase_05 AC 32 ms
52,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 32 ms
53,256 KB
testcase_09 WA -
testcase_10 WA -
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 132 ms
107,552 KB
testcase_21 AC 105 ms
89,560 KB
testcase_22 AC 126 ms
107,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10 ** -9
inf = 10 ** 15


def main():
    import sys
    input = sys.stdin.buffer.readline

    N, Vmax, L = map(int, input().split())
    X = [0] * (N + 1)
    V = [0] * (N + 1)
    W = [0] * (N + 1)
    for i in range(1, N + 1):
        x, v, w = map(int, input().split())
        X[i] = x
        V[i] = v
        W[i] = w
    X.append(L)
    V.append(0)
    W.append(0)

    dp = [[inf] * (Vmax + 1) for _ in range(N + 2)]
    dp[0][Vmax] = 0
    for i in range(1, N + 2):
        x, v, w = X[i], V[i], W[i]
        d = x - X[i-1]
        for j in range(Vmax+1):
            if j - d >= 0:
                dp[i][j-d] = dp[i-1][j]
                dp[i][min(Vmax, j-d + v)] = min(dp[i][min(Vmax, j-d+v)], dp[i-1][j] + w)
    ans = min(dp[-1])
    if ans == inf:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()
0