結果

問題 No.1037 exhausted
ユーザー H3PO4H3PO4
提出日時 2021-10-02 13:15:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 664 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 29,816 KB
最終ジャッジ日時 2023-09-27 12:45:01
合計ジャッジ時間 6,761 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
29,452 KB
testcase_01 AC 119 ms
29,504 KB
testcase_02 AC 124 ms
29,656 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 122 ms
29,464 KB
testcase_06 RE -
testcase_07 AC 118 ms
29,656 KB
testcase_08 AC 116 ms
29,580 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 124 ms
29,652 KB
testcase_21 AC 127 ms
29,492 KB
testcase_22 AC 124 ms
29,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, V, L = map(int, input().split())
INF = 10 ** 18
dp = np.full(V + 1, INF)
dp[V] = 0
cur = 0
for _ in range(N):
    new_dp = np.full(V + 1, INF)
    x, v, w = map(int, input().split())
    dist = x - cur
    if dist > V:
        print(-1)
        exit()
    new_dp[:V + 1 - dist] = dp[dist:]
    dp = new_dp.copy()

    if v <= V:
        new_dp[v:] = np.minimum(new_dp[v:], dp[:-v] + w)
        new_dp[V] = min(new_dp[V], np.min(dp[-v:]) + w)
    else:
        new_dp[V] = min(new_dp[V], np.min(dp) + w)

    dp = new_dp.copy()
    cur = x

if L - cur > V:
    print(-1)
    exit()
ans = np.min(dp[L - cur:])
print(ans if ans != INF else -1)
0