結果

問題 No.1 道のショートカット
ユーザー DrDrpilotDrDrpilot
提出日時 2022-09-05 16:14:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 898 bytes
コンパイル時間 149 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 71,496 KB
最終ジャッジ日時 2024-04-30 19:22:51
合計ジャッジ時間 4,093 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
62,540 KB
testcase_01 AC 52 ms
61,528 KB
testcase_02 AC 52 ms
61,412 KB
testcase_03 AC 50 ms
62,092 KB
testcase_04 AC 49 ms
61,872 KB
testcase_05 AC 49 ms
61,744 KB
testcase_06 AC 49 ms
61,864 KB
testcase_07 AC 51 ms
61,308 KB
testcase_08 AC 72 ms
70,152 KB
testcase_09 AC 63 ms
70,448 KB
testcase_10 AC 66 ms
70,524 KB
testcase_11 AC 75 ms
69,968 KB
testcase_12 AC 107 ms
70,232 KB
testcase_13 AC 105 ms
70,580 KB
testcase_14 AC 56 ms
64,092 KB
testcase_15 AC 51 ms
63,844 KB
testcase_16 AC 58 ms
66,432 KB
testcase_17 AC 52 ms
63,064 KB
testcase_18 AC 55 ms
65,288 KB
testcase_19 AC 58 ms
66,856 KB
testcase_20 AC 63 ms
68,692 KB
testcase_21 AC 61 ms
68,432 KB
testcase_22 AC 57 ms
67,156 KB
testcase_23 AC 78 ms
70,500 KB
testcase_24 AC 79 ms
70,396 KB
testcase_25 AC 64 ms
68,644 KB
testcase_26 AC 60 ms
67,816 KB
testcase_27 AC 83 ms
71,496 KB
testcase_28 AC 52 ms
63,716 KB
testcase_29 AC 65 ms
69,084 KB
testcase_30 AC 57 ms
66,472 KB
testcase_31 AC 61 ms
69,380 KB
testcase_32 AC 69 ms
69,656 KB
testcase_33 AC 66 ms
70,160 KB
testcase_34 AC 77 ms
70,040 KB
testcase_35 AC 53 ms
64,084 KB
testcase_36 AC 65 ms
69,548 KB
testcase_37 AC 56 ms
65,868 KB
testcase_38 AC 52 ms
62,940 KB
testcase_39 AC 55 ms
65,660 KB
testcase_40 AC 58 ms
66,916 KB
testcase_41 AC 52 ms
63,932 KB
testcase_42 AC 49 ms
63,100 KB
testcase_43 AC 50 ms
63,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def I():return int(input())
def MAP():return map(int,input().split())
def MAPs():return map(str,input().split())
def LI(): return list(map(int,input().split()))
def TPL(): return tuple(map(int,input().split()))
def S():return input()
from collections import defaultdict,Counter,deque
from copy import deepcopy
from heapq import heapify,heappop,heappush
from bisect import bisect_left,bisect_right
from itertools import accumulate,product,permutations,combinations
from math import gcd,ceil,floor,sqrt
inf=float('inf')

n=I()
c=I()
v=I()
s=LI()
t=LI()
y=LI()
m=LI()
dp=[[inf]*(c+1) for _ in range(n+1)]
dp[1][c]=0
for i in range(1,n+1):
    for j in range(c,-1,-1):
        if dp[i][j]!=inf:
            for k in range(v):
                if i==s[k] and j-y[k]>=0:
                    dp[t[k]][j-y[k]]=min(dp[i][j]+m[k],dp[t[k]][j-y[k]])
if min(dp[n])==inf:
    print(-1)
else:
    print(min(dp[n]))
0