結果

問題 No.1 道のショートカット
ユーザー konchanksukonchanksu
提出日時 2020-04-28 00:30:58
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 984 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 11,116 KB
実行使用メモリ 9,244 KB
最終ジャッジ日時 2023-09-27 22:27:54
合計ジャッジ時間 3,095 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,116 KB
testcase_01 AC 15 ms
8,120 KB
testcase_02 AC 16 ms
8,116 KB
testcase_03 AC 16 ms
8,132 KB
testcase_04 AC 16 ms
7,812 KB
testcase_05 AC 15 ms
8,116 KB
testcase_06 AC 16 ms
8,192 KB
testcase_07 AC 16 ms
8,124 KB
testcase_08 AC 35 ms
9,072 KB
testcase_09 AC 23 ms
8,864 KB
testcase_10 AC 28 ms
8,504 KB
testcase_11 AC 58 ms
8,524 KB
testcase_12 AC 94 ms
9,244 KB
testcase_13 AC 84 ms
9,128 KB
testcase_14 AC 18 ms
8,308 KB
testcase_15 AC 18 ms
8,492 KB
testcase_16 AC 18 ms
8,496 KB
testcase_17 AC 17 ms
8,196 KB
testcase_18 AC 17 ms
8,528 KB
testcase_19 AC 18 ms
8,704 KB
testcase_20 AC 25 ms
8,680 KB
testcase_21 AC 20 ms
8,652 KB
testcase_22 AC 17 ms
8,200 KB
testcase_23 AC 135 ms
8,492 KB
testcase_24 AC 128 ms
8,452 KB
testcase_25 AC 35 ms
8,576 KB
testcase_26 AC 24 ms
8,108 KB
testcase_27 AC 106 ms
8,624 KB
testcase_28 AC 16 ms
8,196 KB
testcase_29 AC 32 ms
8,576 KB
testcase_30 AC 18 ms
8,100 KB
testcase_31 AC 30 ms
8,208 KB
testcase_32 AC 39 ms
8,880 KB
testcase_33 AC 26 ms
8,644 KB
testcase_34 AC 98 ms
8,568 KB
testcase_35 AC 18 ms
8,104 KB
testcase_36 AC 22 ms
8,556 KB
testcase_37 AC 18 ms
8,076 KB
testcase_38 AC 18 ms
8,260 KB
testcase_39 AC 20 ms
8,500 KB
testcase_40 AC 17 ms
8,184 KB
testcase_41 AC 16 ms
8,280 KB
testcase_42 AC 16 ms
8,072 KB
testcase_43 AC 20 ms
8,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = int(input())
V = int(input())
S = [[i] for i in 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())) # 時間

NUM = [0 for i in range(N + 1)]
for i in range(V):
    S[i] += [T[i], Y[i], M[i]] # 行く前 行った後 コスト 時間
    NUM[S[i][0] + 1] += 1

S.sort(key=lambda x:x[0])
for i in range(1, N + 1):
    NUM[i] += NUM[i - 1]


dp = [[float('inf') for i in range(C + 1)] for j in range(N)]
dp[0][0] = 0

for i in range(N):
    for j in range(C + 1):
        if dp[i][j] != float('inf'):
            for k in range(NUM[i], NUM[i + 1]):
                if S[k][2] + j > C:
                    continue
                dp[S[k][1]][S[k][2] + j] = min(dp[S[k][1]][S[k][2] + j], dp[i][j] + S[k][3])

ans = float('inf')
for i in dp[N - 1]:
    ans = min(ans, i)

print(ans if ans != float('inf') else -1)
0