結果
問題 |
No.31 悪のミックスジュース
|
ユーザー |
|
提出日時 | 2022-01-01 14:09:03 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 73 ms / 5,000 ms |
コード長 | 631 bytes |
コンパイル時間 | 353 ms |
コンパイル使用メモリ | 82,564 KB |
実行使用メモリ | 71,632 KB |
最終ジャッジ日時 | 2024-10-10 03:24:18 |
合計ジャッジ時間 | 2,203 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
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-10000)//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])