結果

問題 No.1 道のショートカット
ユーザー kamiyomokikanukamiyomokikanu
提出日時 2019-08-16 23:42:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,371 bytes
コンパイル時間 845 ms
コンパイル使用メモリ 86,952 KB
実行使用メモリ 77,336 KB
最終ジャッジ日時 2023-09-22 13:33:35
合計ジャッジ時間 8,742 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
76,776 KB
testcase_01 AC 101 ms
76,792 KB
testcase_02 AC 104 ms
77,336 KB
testcase_03 AC 91 ms
71,464 KB
testcase_04 AC 92 ms
71,676 KB
testcase_05 AC 103 ms
77,308 KB
testcase_06 AC 93 ms
71,432 KB
testcase_07 AC 96 ms
76,708 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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()))

#print(S)
#print(T)
#print(Y)
#print(M)

p=[]
for i in range(V):
    p.append([S[i],T[i],Y[i],M[i]])

#print (p)

l=[[] for i in range(N+1)]
lw=[[] for i in range(N+1)]
lt=[[] for i in range(N+1)]
for pi in p:
    l[pi[0]].append(pi[1])
    l[pi[1]].append(pi[0])
    lw[pi[0]].append(pi[2])
    lw[pi[1]].append(pi[2])
    lt[pi[0]].append(pi[3])
    lt[pi[1]].append(pi[3])

#print(l)
#print(lw)
#print(lt)

stack=deque([1])
dp=[[-1 for i in range(C+1)] for j in range(N+1)]
dp[1][0]=0

while len(stack) > 0:
    n=stack.pop()
    #print (n)
    for i in range(len(l[n])):
        nt=l[n][i]
        ntw=lw[n][i]
        ntt=lt[n][i]
        #print(str(nt)+","+str(ntw)+","+str(ntt))
        for j in range(C+1):
            if dp[n][j]!=-1:
                tw=j+ntw
                tt=dp[n][j]+ntt
                #print(str(tw)+"-"+str(tt))
                if tw>C:continue
                if dp[nt][tw]==-1 or tt<dp[nt][tw]:
                    dp[nt][tw]=tt
                    stack.append(nt)

#print(dp)

ans=-1
for dpi in dp[N]:
    if(dpi!=-1):
        if(ans==-1):
            ans=dpi
        else:
            ans=min(ans,dpi)

print (str(ans))
0