結果
問題 | No.1 道のショートカット |
ユーザー | DialBird |
提出日時 | 2019-07-16 23:34:53 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,135 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 11,052 KB |
実行使用メモリ | 8,708 KB |
最終ジャッジ日時 | 2023-09-22 13:32:50 |
合計ジャッジ時間 | 3,136 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
8,056 KB |
testcase_01 | AC | 16 ms
8,084 KB |
testcase_02 | AC | 16 ms
8,068 KB |
testcase_03 | AC | 16 ms
8,028 KB |
testcase_04 | AC | 16 ms
8,116 KB |
testcase_05 | AC | 17 ms
8,052 KB |
testcase_06 | AC | 17 ms
8,076 KB |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 18 ms
8,504 KB |
testcase_10 | AC | 18 ms
8,508 KB |
testcase_11 | RE | - |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | AC | 17 ms
8,188 KB |
testcase_15 | RE | - |
testcase_16 | AC | 17 ms
8,068 KB |
testcase_17 | AC | 16 ms
8,068 KB |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | AC | 16 ms
8,172 KB |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
testcase_30 | RE | - |
testcase_31 | RE | - |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | AC | 18 ms
8,452 KB |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | AC | 16 ms
8,280 KB |
testcase_39 | AC | 17 ms
8,376 KB |
testcase_40 | AC | 17 ms
8,044 KB |
testcase_41 | RE | - |
testcase_42 | AC | 16 ms
8,068 KB |
testcase_43 | RE | - |
ソースコード
from heapq import heappop, heappush def main(): """ main """ 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())) ways_from = {} for i in range(V): if ways_from.get(S[i]): ways_from[S[i]].append({'next': T[i], 'cost': Y[i], 'min': M[i]}) else: ways_from[S[i]] = [{'next': T[i], 'cost': Y[i], 'min': M[i]}] candidates = [(0, {'pos': 1, 'cost': 0})] res = None while candidates: candidate = heappop(candidates) if candidate[1]['pos'] == N: res = candidate[0] break if not ways_from[candidate[1]['pos']]: continue for way in ways_from[candidate[1]['pos']]: next_cost = candidate[1]['cost'] + way['cost'] if C < next_cost: continue heappush( candidates, (candidate[0] + way['min'], {'pos': way['next'], 'cost': next_cost})) return res or -1 print(main())