結果

問題 No.1 道のショートカット
ユーザー szkhts
提出日時 2020-06-05 11:06:26
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 745 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-07-20 16:49:04
合計ジャッジ時間 3,317 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = int(input())
V = int(input())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
z = zip(S, T, Y, M)

dp = [[None] * (C + 1) for i in range(N)]
dp[0][0] = 0

for s, t, y, m in sorted(z, key = lambda x:(x[0], x[1])):
    for j in range(C + 1):
        a = dp[s - 1][j]
        if a is not None:
            q = y + j
            if C < q:
                break
            p = t - 1
            x = a + m
            if dp[p][q] is None or x < dp[p][q]:
                dp[p][q] = x

o = None
for x in dp[N - 1]:
    if x is not None:
        if o is None or x < o:
            o = x

if o is None:
    print(-1)
else:
    print(o)
0