結果

問題 No.1 道のショートカット
ユーザー maatanbetamaatanbeta
提出日時 2017-05-19 16:02:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 403 ms / 5,000 ms
コード長 676 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 10,788 KB
実行使用メモリ 11,060 KB
最終ジャッジ日時 2023-09-27 22:05:49
合計ジャッジ時間 5,568 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
7,760 KB
testcase_01 AC 13 ms
7,760 KB
testcase_02 AC 13 ms
7,856 KB
testcase_03 AC 13 ms
7,756 KB
testcase_04 AC 13 ms
7,880 KB
testcase_05 AC 13 ms
7,864 KB
testcase_06 AC 13 ms
7,728 KB
testcase_07 AC 13 ms
7,900 KB
testcase_08 AC 102 ms
9,616 KB
testcase_09 AC 73 ms
9,444 KB
testcase_10 AC 90 ms
8,980 KB
testcase_11 AC 231 ms
9,116 KB
testcase_12 AC 341 ms
10,560 KB
testcase_13 AC 403 ms
10,900 KB
testcase_14 AC 14 ms
8,244 KB
testcase_15 AC 13 ms
7,840 KB
testcase_16 AC 26 ms
8,840 KB
testcase_17 AC 13 ms
7,868 KB
testcase_18 AC 16 ms
8,328 KB
testcase_19 AC 18 ms
8,372 KB
testcase_20 AC 53 ms
8,880 KB
testcase_21 AC 38 ms
8,740 KB
testcase_22 AC 22 ms
8,436 KB
testcase_23 AC 193 ms
8,628 KB
testcase_24 AC 193 ms
8,676 KB
testcase_25 AC 58 ms
8,672 KB
testcase_26 AC 30 ms
8,436 KB
testcase_27 AC 347 ms
9,036 KB
testcase_28 AC 14 ms
7,664 KB
testcase_29 AC 75 ms
8,556 KB
testcase_30 AC 20 ms
8,136 KB
testcase_31 AC 28 ms
8,216 KB
testcase_32 AC 332 ms
11,060 KB
testcase_33 AC 176 ms
10,544 KB
testcase_34 AC 289 ms
9,472 KB
testcase_35 AC 15 ms
8,200 KB
testcase_36 AC 82 ms
8,896 KB
testcase_37 AC 19 ms
8,348 KB
testcase_38 AC 14 ms
7,744 KB
testcase_39 AC 18 ms
8,396 KB
testcase_40 AC 25 ms
8,536 KB
testcase_41 AC 14 ms
8,348 KB
testcase_42 AC 12 ms
7,900 KB
testcase_43 AC 13 ms
7,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()))
dic = {}


def sum_time(t, y):
    if (t, y) in dic:
        return dic[(t, y)]

    if y < 0:
        dic[(t, y)] = float("inf")
        return dic[(t, y)]

    if t == 1:
        dic[(t, y)] = 0
        return dic[(t, y)]

    minm = float("inf")
    for i in range(V):
        if t == T[i]:
            minm = min(sum_time(S[i], y-Y[i]) + M[i], minm)
    dic[(t, y)] = minm
    return dic[(t, y)]


M = sum_time(N, C)
if float("inf") > M >= 0:
    print(M)
else:
    print(-1)
0