結果

問題 No.1 道のショートカット
ユーザー rarpipipirarpipipi
提出日時 2023-12-31 03:33:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 776 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 72,920 KB
最終ジャッジ日時 2023-12-31 03:33:33
合計ジャッジ時間 3,715 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
55,612 KB
testcase_01 AC 38 ms
55,612 KB
testcase_02 AC 38 ms
55,612 KB
testcase_03 AC 38 ms
55,612 KB
testcase_04 AC 38 ms
55,612 KB
testcase_05 AC 38 ms
55,612 KB
testcase_06 AC 38 ms
55,612 KB
testcase_07 AC 40 ms
55,612 KB
testcase_08 AC 56 ms
68,624 KB
testcase_09 AC 47 ms
64,180 KB
testcase_10 AC 54 ms
68,456 KB
testcase_11 AC 60 ms
70,704 KB
testcase_12 AC 64 ms
72,920 KB
testcase_13 AC 62 ms
70,700 KB
testcase_14 AC 39 ms
55,612 KB
testcase_15 AC 39 ms
55,612 KB
testcase_16 AC 40 ms
55,612 KB
testcase_17 AC 39 ms
55,612 KB
testcase_18 AC 39 ms
55,612 KB
testcase_19 AC 43 ms
55,612 KB
testcase_20 AC 44 ms
61,528 KB
testcase_21 AC 39 ms
55,612 KB
testcase_22 AC 39 ms
55,612 KB
testcase_23 AC 62 ms
70,832 KB
testcase_24 AC 62 ms
70,716 KB
testcase_25 AC 44 ms
61,528 KB
testcase_26 AC 42 ms
55,612 KB
testcase_27 AC 62 ms
70,848 KB
testcase_28 AC 38 ms
55,612 KB
testcase_29 AC 60 ms
70,700 KB
testcase_30 AC 50 ms
63,928 KB
testcase_31 AC 57 ms
68,464 KB
testcase_32 AC 54 ms
66,380 KB
testcase_33 AC 49 ms
64,308 KB
testcase_34 AC 61 ms
70,700 KB
testcase_35 AC 51 ms
66,500 KB
testcase_36 AC 53 ms
66,372 KB
testcase_37 AC 54 ms
66,380 KB
testcase_38 AC 39 ms
55,612 KB
testcase_39 AC 40 ms
55,612 KB
testcase_40 AC 41 ms
55,612 KB
testcase_41 AC 40 ms
55,612 KB
testcase_42 AC 38 ms
55,612 KB
testcase_43 AC 37 ms
55,612 KB
権限があれば一括ダウンロードができます

ソースコード

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:
                for niy,nim in dp[ni]:
                    if niy<cy+ny and nim<cm+nm:
                        break
                else:
                    dp[ni].append((cy+ny,cm+nm))

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