結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
tookunn_1213
|
| 提出日時 | 2016-08-22 21:43:11 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 721 bytes |
| コンパイル時間 | 118 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-07-08 04:29:55 |
| 合計ジャッジ時間 | 2,265 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 16 WA * 24 |
ソースコード
import heapq N,C,V = int(input()),int(input()),int(input()) S = [int(i) - 1 for i in input().split()] T = [int(i) - 1 for i in input().split()] Y = [int(i) for i in input().split()] M = [int(i) for i in input().split()] cost = [[-1 for j in range(N)]for i in range(N)] time = [[-1 for j in range(N)] for i in range(N)] for i in range(V): cost[S[i]][T[i]] = Y[i] for i in range(V): time[S[i]][T[i]] = M[i] def dijkstra(): q = [(0,C,0)] while len(q) > 0: d = heapq.heappop(q) if d[2] == N - 1 and d[1] >= 0: return d[0] for i in range(N): if d[2] == i or cost[d[2]][i] == -1 or time[d[2]][i] == -1: continue heapq.heappush(q,(d[0] + time[d[2]][i],d[1] - cost[d[2]][i],i)) return -1 print(dijkstra())
tookunn_1213