結果

問題 No.1 道のショートカット
ユーザー rarpipipi
提出日時 2023-12-31 03:31:19
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 633 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 848,988 KB
最終ジャッジ日時 2024-09-27 17:00:38
合計ジャッジ時間 5,273 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 MLE * 1 -- * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

INF=float('inf')
n=int(input())
c=int(input())
v=int(input())

from collections import defaultdict
edge=defaultdict(list)

s=list(map(lambda x:int(x)-1,input().split()))
t=list(map(lambda x:int(x)-1,input().split()))
y=list(map(int,input().split()))
m=list(map(int,input().split()))
for i in range(v):
    si,ti,yi,mi=s[i],t[i],y[i],m[i]
    edge[si].append((ti,yi,mi))

dp=[[] for i in range(n)]
dp[0]=[(0,0)]
for ci in range(n):
    for cy,cm in dp[ci]:
        for ni,ny,nm in edge[ci]:
            if cy+ny<=c:
                dp[ni].append((cy+ny,cm+nm))

if dp[-1]:
    print(min([mm for yy,mm in dp[-1]]))
else:
    print(-1)
0