結果

問題 No.1 道のショートカット
ユーザー zarath8128
提出日時 2018-03-11 13:46:02
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 652 bytes
コンパイル時間 83 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-07-20 16:34:56
合計ジャッジ時間 2,598 ms
ジャッジサーバーID
(参考情報)
judge1 / 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()))

G = sorted([(S[i], T[i], Y[i], M[i]) for i in range(0, V)])

L = [set() for i in range(1, N + 1)]
L[0].add((0, 0))

for (s, t, y, m) in G:
    for (y2, m2) in L[s - 1]:
        if y2 + y <= C:
            for (y3, m3) in L[t - 1]:
                if y3 < y2 + y and m3 < m2 + m:
                    break
            else:
                L[t - 1].add((y + y2, m + m2))

if L[N - 1] == set():
    print(-1)
else:
    print(min([t for (c, t) in L[N - 1]]))
0