結果
問題 | No.1 道のショートカット |
ユーザー |
![]() |
提出日時 | 2017-05-19 16:02:22 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 566 ms / 5,000 ms |
コード長 | 676 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 13,520 KB |
最終ジャッジ日時 | 2024-07-20 16:29:51 |
合計ジャッジ時間 | 6,576 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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())) dic = {} def sum_time(t, y): if (t, y) in dic: return dic[(t, y)] if y < 0: dic[(t, y)] = float("inf") return dic[(t, y)] if t == 1: dic[(t, y)] = 0 return dic[(t, y)] minm = float("inf") for i in range(V): if t == T[i]: minm = min(sum_time(S[i], y-Y[i]) + M[i], minm) dic[(t, y)] = minm return dic[(t, y)] M = sum_time(N, C) if float("inf") > M >= 0: print(M) else: print(-1)