結果

問題 No.1 道のショートカット
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2022-10-10 08:30:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 143 ms / 5,000 ms
コード長 897 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 86,384 KB
実行使用メモリ 78,368 KB
最終ジャッジ日時 2023-09-06 09:33:46
合計ジャッジ時間 8,012 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
72,896 KB
testcase_01 AC 113 ms
72,828 KB
testcase_02 AC 110 ms
72,696 KB
testcase_03 AC 114 ms
72,752 KB
testcase_04 AC 112 ms
72,852 KB
testcase_05 AC 112 ms
72,656 KB
testcase_06 AC 111 ms
72,832 KB
testcase_07 AC 118 ms
77,236 KB
testcase_08 AC 140 ms
78,368 KB
testcase_09 AC 131 ms
78,012 KB
testcase_10 AC 130 ms
78,188 KB
testcase_11 AC 133 ms
78,156 KB
testcase_12 AC 143 ms
78,140 KB
testcase_13 AC 143 ms
78,128 KB
testcase_14 AC 123 ms
77,440 KB
testcase_15 AC 112 ms
72,864 KB
testcase_16 AC 128 ms
77,900 KB
testcase_17 AC 120 ms
77,516 KB
testcase_18 AC 123 ms
77,844 KB
testcase_19 AC 124 ms
77,484 KB
testcase_20 AC 128 ms
78,012 KB
testcase_21 AC 126 ms
77,976 KB
testcase_22 AC 123 ms
77,396 KB
testcase_23 AC 134 ms
78,208 KB
testcase_24 AC 136 ms
78,256 KB
testcase_25 AC 127 ms
77,824 KB
testcase_26 AC 125 ms
77,800 KB
testcase_27 AC 133 ms
78,012 KB
testcase_28 AC 118 ms
77,632 KB
testcase_29 AC 133 ms
78,312 KB
testcase_30 AC 128 ms
77,904 KB
testcase_31 AC 127 ms
78,172 KB
testcase_32 AC 130 ms
78,040 KB
testcase_33 AC 130 ms
78,176 KB
testcase_34 AC 135 ms
78,120 KB
testcase_35 AC 128 ms
78,152 KB
testcase_36 AC 125 ms
78,264 KB
testcase_37 AC 129 ms
78,200 KB
testcase_38 AC 120 ms
77,572 KB
testcase_39 AC 124 ms
77,868 KB
testcase_40 AC 124 ms
77,892 KB
testcase_41 AC 124 ms
77,856 KB
testcase_42 AC 112 ms
72,664 KB
testcase_43 AC 116 ms
72,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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()))
INF = (1<<60)
dp = [[INF]*(C+2) for _ in range(N)]
e = [[] for _ in range(N)]
for i in range(V):
    
    s,t,y,m = S[i],T[i],Y[i],M[i]
    
    s -= 1
    t -= 1
    e[s].append((t,y,m))
    e[t].append((s,y,m))
    
dp[0][0] = 0

def f(x):
    
    return min(x,C+1)
    
for i in range(N-1):
    
    
    for v,y,m in e[i]:
        
        for j in range(C+1):
            
            
            dp[v][f(j+y)] = min(dp[v][f(j+y)],dp[i][j]+m)
            
ans = min(dp[-1][:C+1])
if ans==INF:
    print(-1)
else:
    print(ans)
    
0