結果

問題 No.1 道のショートカット
ユーザー DrDrpilotDrDrpilot
提出日時 2022-09-05 16:14:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,467 ms / 5,000 ms
コード長 898 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-30 19:23:24
合計ジャッジ時間 9,883 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
11,264 KB
testcase_01 AC 31 ms
11,136 KB
testcase_02 AC 33 ms
11,264 KB
testcase_03 AC 35 ms
11,264 KB
testcase_04 AC 33 ms
11,136 KB
testcase_05 AC 32 ms
11,136 KB
testcase_06 AC 33 ms
11,136 KB
testcase_07 AC 32 ms
11,264 KB
testcase_08 AC 396 ms
11,392 KB
testcase_09 AC 90 ms
11,392 KB
testcase_10 AC 241 ms
11,264 KB
testcase_11 AC 404 ms
11,392 KB
testcase_12 AC 1,467 ms
11,520 KB
testcase_13 AC 1,295 ms
11,520 KB
testcase_14 AC 34 ms
11,136 KB
testcase_15 AC 33 ms
11,264 KB
testcase_16 AC 41 ms
11,136 KB
testcase_17 AC 32 ms
11,264 KB
testcase_18 AC 36 ms
11,136 KB
testcase_19 AC 34 ms
11,136 KB
testcase_20 AC 80 ms
11,264 KB
testcase_21 AC 43 ms
11,264 KB
testcase_22 AC 33 ms
11,136 KB
testcase_23 AC 568 ms
11,264 KB
testcase_24 AC 493 ms
11,264 KB
testcase_25 AC 109 ms
11,136 KB
testcase_26 AC 62 ms
11,136 KB
testcase_27 AC 736 ms
11,392 KB
testcase_28 AC 31 ms
11,136 KB
testcase_29 AC 145 ms
11,264 KB
testcase_30 AC 43 ms
11,136 KB
testcase_31 AC 63 ms
11,136 KB
testcase_32 AC 291 ms
11,392 KB
testcase_33 AC 133 ms
11,264 KB
testcase_34 AC 541 ms
11,264 KB
testcase_35 AC 33 ms
11,264 KB
testcase_36 AC 94 ms
11,264 KB
testcase_37 AC 45 ms
11,264 KB
testcase_38 AC 31 ms
11,136 KB
testcase_39 AC 34 ms
11,264 KB
testcase_40 AC 38 ms
11,136 KB
testcase_41 AC 31 ms
11,136 KB
testcase_42 AC 32 ms
11,264 KB
testcase_43 AC 34 ms
11,136 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