結果

問題 No.31 悪のミックスジュース
ユーザー maspymaspy
提出日時 2020-03-31 13:52:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 87,356 KB
実行使用メモリ 76,684 KB
最終ジャッジ日時 2023-09-06 15:55:49
合計ジャッジ時間 2,721 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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, 1 + (V - U) // n)
answer += k * C[n - 1]
if V > 0:
    print(V - k * n)
    answer += dp[V - k * n]
print(answer)
0