結果
| 問題 |
No.31 悪のミックスジュース
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-23 14:24:44 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 701 bytes |
| コンパイル時間 | 167 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 107,904 KB |
| 最終ジャッジ日時 | 2024-11-29 14:21:24 |
| 合計ジャッジ時間 | 10,541 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 14 |
ソースコード
import itertools
import sys
import fractions
input = sys.stdin.readline
def main():
N, V = map(int, input().split())
*C, = itertools.accumulate(map(int, input().split()))
V -= N
if V <= 0:
print(C[-1])
return
L = (N**3-N)//2
DP = [0] + [float('inf')]*L
for i in range(1, L+1):
for j in range(N):
if i > j:
DP[i] = min(DP[i], DP[i-(j+1)]+C[j])
if V <= L:
print(C[-1] + DP[V])
else:
target = min(range(N), key=lambda i: fractions.Fraction(C[i], i+1))
greedy = (V-(L+1))//(target+1) + 1
print(greedy*C[target] + DP[V-(target+1)*greedy])
if __name__ == '__main__':
main()