結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2025-03-24 02:07:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 479 ms / 5,000 ms |
コード長 | 540 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 17,792 KB |
最終ジャッジ日時 | 2025-03-24 02:07:25 |
合計ジャッジ時間 | 5,369 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 40 |
ソースコード
import heapq n=int(input()) c=int(input()) v=int(input()) u=list(map(int,input().split())) w=list(map(int,input().split())) x=list(map(int,input().split())) m=list(map(int,input().split())) a=[[] for i in range(n)] for i in range(v): a[u[i]-1].append([w[i]-1,x[i],m[i]]) dp=[[10**9]*(c+1) for i in range(n)] x=[] heapq.heappush(x,[0,c,0]) while len(x): q,w,e=heapq.heappop(x) if dp[e][w]!=10**9: continue dp[e][w]=q for i,j,l in a[e]: if w-j<0: continue heapq.heappush(x,[q+l,w-j,i]) x=min(dp[-1]) if x==10**9: x=-1 print(x)