結果

問題 No.31 悪のミックスジュース
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-01-01 14:04:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 133 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 64,260 KB
最終ジャッジ日時 2024-04-18 10:02:38
合計ジャッジ時間 1,519 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,352 KB
testcase_01 AC 54 ms
61,824 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 46 ms
60,288 KB
testcase_05 AC 45 ms
60,032 KB
testcase_06 AC 36 ms
51,456 KB
testcase_07 AC 51 ms
61,696 KB
testcase_08 AC 50 ms
61,824 KB
testcase_09 WA -
testcase_10 AC 33 ms
51,840 KB
testcase_11 AC 44 ms
61,184 KB
testcase_12 AC 47 ms
61,952 KB
testcase_13 AC 37 ms
58,240 KB
testcase_14 AC 48 ms
61,824 KB
testcase_15 AC 44 ms
60,800 KB
testcase_16 AC 46 ms
61,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,v = map(int,input().split())
C = list(map(int,input().split()))

cost = []
now = 0

mnum = 0
mcost = 0
for i,c in enumerate(C,1):
    now += c
    cost.append(now)
    if mnum == 0:
        mnum = i
        mcost = now
        continue

    if mcost*i > now*mnum:
        mnum = i
        mcost = now

base = sum(C)
v -= min(v,n)
took = max(0,(v-2000)//mnum)
base += took*mcost
v -= took*mnum

inf = 10**30
dp = [inf]*(v+1)
dp[0] = 0
for i, c in enumerate(cost,1):
    for j in range(v+1):
        if dp[j] == inf:
            continue
        if j + i <= v:
            dp[j+i] = min(dp[j+i],dp[j]+c)

print(base+dp[-1])


    
0