結果

問題 No.1 道のショートカット
ユーザー tassei903tassei903
提出日時 2022-03-25 18:04:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 931 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 75,136 KB
最終ジャッジ日時 2024-04-22 03:41:30
合計ジャッジ時間 4,357 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,840 KB
testcase_01 AC 40 ms
51,968 KB
testcase_02 AC 40 ms
52,352 KB
testcase_03 AC 39 ms
52,352 KB
testcase_04 AC 39 ms
51,968 KB
testcase_05 AC 39 ms
52,736 KB
testcase_06 AC 39 ms
52,352 KB
testcase_07 AC 40 ms
52,736 KB
testcase_08 AC 97 ms
72,448 KB
testcase_09 AC 74 ms
71,936 KB
testcase_10 AC 73 ms
71,936 KB
testcase_11 AC 75 ms
73,088 KB
testcase_12 AC 87 ms
75,136 KB
testcase_13 AC 84 ms
74,496 KB
testcase_14 AC 69 ms
70,016 KB
testcase_15 AC 46 ms
59,776 KB
testcase_16 AC 68 ms
70,016 KB
testcase_17 AC 53 ms
62,976 KB
testcase_18 AC 66 ms
69,248 KB
testcase_19 AC 71 ms
71,040 KB
testcase_20 AC 68 ms
69,888 KB
testcase_21 AC 67 ms
69,376 KB
testcase_22 AC 63 ms
67,968 KB
testcase_23 AC 73 ms
70,784 KB
testcase_24 AC 73 ms
70,912 KB
testcase_25 AC 71 ms
70,144 KB
testcase_26 AC 66 ms
68,224 KB
testcase_27 AC 76 ms
72,704 KB
testcase_28 AC 53 ms
62,976 KB
testcase_29 AC 64 ms
67,840 KB
testcase_30 AC 53 ms
62,592 KB
testcase_31 AC 57 ms
65,024 KB
testcase_32 AC 80 ms
73,600 KB
testcase_33 AC 73 ms
70,016 KB
testcase_34 AC 76 ms
72,576 KB
testcase_35 AC 49 ms
61,184 KB
testcase_36 AC 68 ms
69,248 KB
testcase_37 AC 51 ms
62,908 KB
testcase_38 AC 55 ms
64,000 KB
testcase_39 AC 71 ms
71,552 KB
testcase_40 AC 60 ms
66,560 KB
testcase_41 AC 50 ms
61,952 KB
testcase_42 AC 39 ms
52,608 KB
testcase_43 AC 45 ms
60,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

N = ni()
C = ni()
V = ni()
S = na()
T = na()
Y = na()
M = na()
G = [[] for i in range(N)]

for i in range(V):
    S[i] -= 1
    T[i] -= 1
    G[S[i]].append((T[i], Y[i], M[i]))
dist = [[float("inf")for j in range(C+1)]for i in range(N)]

for i in range(C+1):
    dist[0][i] = 0

for i in range(N):
    for j in range(C+1):
        now = dist[i][j]
        for t, y, m in G[i]:
            nj = j + y
            if nj > C:
                continue
            dist[t][nj] = min(dist[t][nj], now + m)
if min(dist[-1])==float("inf"):
    print(-1)
else:
    print(min(dist[-1]))
0