結果

問題 No.1 道のショートカット
ユーザー Woo-CieWoo-Cie
提出日時 2019-03-23 13:24:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 309 ms / 5,000 ms
コード長 804 bytes
コンパイル時間 131 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 30,064 KB
最終ジャッジ日時 2023-09-27 22:18:49
合計ジャッジ時間 11,110 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
29,672 KB
testcase_01 AC 135 ms
29,636 KB
testcase_02 AC 136 ms
29,540 KB
testcase_03 AC 135 ms
29,624 KB
testcase_04 AC 138 ms
29,696 KB
testcase_05 AC 135 ms
29,680 KB
testcase_06 AC 137 ms
29,452 KB
testcase_07 AC 138 ms
29,660 KB
testcase_08 AC 156 ms
29,832 KB
testcase_09 AC 145 ms
29,780 KB
testcase_10 AC 150 ms
29,844 KB
testcase_11 AC 190 ms
29,668 KB
testcase_12 AC 226 ms
30,064 KB
testcase_13 AC 216 ms
29,820 KB
testcase_14 AC 139 ms
29,704 KB
testcase_15 AC 140 ms
29,536 KB
testcase_16 AC 138 ms
29,608 KB
testcase_17 AC 139 ms
29,572 KB
testcase_18 AC 138 ms
29,580 KB
testcase_19 AC 142 ms
29,692 KB
testcase_20 AC 149 ms
29,668 KB
testcase_21 AC 140 ms
29,740 KB
testcase_22 AC 139 ms
29,668 KB
testcase_23 AC 309 ms
29,648 KB
testcase_24 AC 289 ms
29,700 KB
testcase_25 AC 158 ms
29,720 KB
testcase_26 AC 147 ms
29,516 KB
testcase_27 AC 253 ms
29,648 KB
testcase_28 AC 135 ms
29,716 KB
testcase_29 AC 159 ms
29,856 KB
testcase_30 AC 139 ms
29,556 KB
testcase_31 AC 156 ms
29,684 KB
testcase_32 AC 165 ms
29,872 KB
testcase_33 AC 147 ms
29,744 KB
testcase_34 AC 238 ms
29,856 KB
testcase_35 AC 136 ms
29,708 KB
testcase_36 AC 142 ms
29,712 KB
testcase_37 AC 136 ms
29,588 KB
testcase_38 AC 134 ms
29,620 KB
testcase_39 AC 135 ms
29,688 KB
testcase_40 AC 137 ms
29,704 KB
testcase_41 AC 136 ms
29,636 KB
testcase_42 AC 135 ms
29,660 KB
testcase_43 AC 137 ms
29,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8-*-
import numpy as np
if __name__ == '__main__':
    INF = 10000000
    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(" ")))
    vl = [ [] for i in range(n)]
    for i in range(v):
        vl[s[i]-1].append((t[i]-1, y[i], m[i]))
    t = np.full((n, c+1), INF)
    t[0,0] = 0
    for i in range(n):
        for j in range(c+1):
            if t[i, j] == INF:
                continue
            for tt, yy, mm in vl[i]:
                if j+yy <= c:
                    t[tt, j+yy] = min(t[i, j] + mm, t[tt, j+yy])
    a = min(t[n-1, :])
    if a == INF:
        a = -1
    print(a)
0