結果

問題 No.31 悪のミックスジュース
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-01-01 13:52:35
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 614 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,860 KB
実行使用メモリ 62,200 KB
最終ジャッジ日時 2024-04-18 09:51:36
合計ジャッジ時間 1,670 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,160 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 42 ms
60,172 KB
testcase_05 AC 42 ms
60,472 KB
testcase_06 AC 36 ms
52,460 KB
testcase_07 AC 41 ms
59,220 KB
testcase_08 AC 42 ms
60,764 KB
testcase_09 WA -
testcase_10 AC 36 ms
52,744 KB
testcase_11 AC 41 ms
60,120 KB
testcase_12 AC 44 ms
60,776 KB
testcase_13 AC 34 ms
52,644 KB
testcase_14 AC 41 ms
60,140 KB
testcase_15 WA -
testcase_16 AC 42 ms
60,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

cost = []
now = 0
mi = 10**20
mnum = 0
mcost = 0
for i,c in enumerate(C,1):
    now += c
    cost.append([now/i,now])
    if mi > now/i:
        mi = min(mi,now/i)
        mnum = i
        mcost= now
base = 0

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

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

print(base+dp[-1])


    
0