結果
問題 | No.1 道のショートカット |
ユーザー |
![]() |
提出日時 | 2019-03-18 00:10:51 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 56 ms / 5,000 ms |
コード長 | 986 bytes |
コンパイル時間 | 100 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-07-20 16:38:30 |
合計ジャッジ時間 | 2,901 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
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())) town = [[(None, None)] for i in range(N)] town[0] = [(0, 0)] for i in range(N): for v in range(V): if S[v]-1 == i: for t in town[i]: if t[0] is None: continue cost = t[0] + Y[v] if cost > C: continue time = t[1] + M[v] if town[T[v]-1][0] == (None, None): town[T[v]-1][0] = (cost, time) else: for t1 in town[T[v]-1]: if cost > t1[0] and time > t1[1]: break else: town[T[v]-1].append((cost, time)) ans = 1000 * N if town[N-1][0] == (None, None): ans = -1 else: for t in town[N-1]: if ans > t[1]: ans = t[1] print(ans)