結果

問題 No.31 悪のミックスジュース
ユーザー maspymaspy
提出日時 2020-03-31 13:50:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 616 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 10,940 KB
実行使用メモリ 8,892 KB
最終ジャッジ日時 2023-09-06 15:52:38
合計ジャッジ時間 5,008 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
8,680 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 20 ms
8,716 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 311 ms
8,668 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools

N, V, *C = map(int, read().split())
C = tuple(itertools.accumulate(C))
V -= N
answer = C[-1]

U = 10010
# cost -> value
INF = 10 ** 18
dp = [INF] * U
dp[0] = 0
for i, x in enumerate(C, 1):
    for j in range(i, U):
        c = dp[j - i] + x
        if dp[j] > c:
            dp[j] = c

rate = [x / i for i, x in enumerate(C, 1)]
n = rate.index(min(rate)) + 1

k = max(0, (V - U) // n)
answer += k * C[n - 1]
if V > 0:
    answer += dp[V - k * n]
print(answer)
0