結果

問題 No.31 悪のミックスジュース
ユーザー vwxyzvwxyz
提出日時 2024-02-27 08:47:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 893 ms / 5,000 ms
コード長 410 bytes
コンパイル時間 183 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-02-27 08:47:25
合計ジャッジ時間 9,671 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,112 KB
testcase_01 AC 573 ms
10,496 KB
testcase_02 AC 580 ms
10,496 KB
testcase_03 AC 855 ms
10,624 KB
testcase_04 AC 835 ms
10,624 KB
testcase_05 AC 862 ms
10,624 KB
testcase_06 AC 28 ms
10,112 KB
testcase_07 AC 829 ms
10,624 KB
testcase_08 AC 877 ms
10,624 KB
testcase_09 AC 893 ms
10,624 KB
testcase_10 AC 692 ms
10,624 KB
testcase_11 AC 42 ms
10,112 KB
testcase_12 AC 316 ms
10,368 KB
testcase_13 AC 28 ms
10,112 KB
testcase_14 AC 839 ms
10,624 KB
testcase_15 AC 33 ms
10,112 KB
testcase_16 AC 63 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V=map(int,input().split())
C=[0]+list(map(int,input().split()))
for v in range(1,N+1):
    C[v]+=C[v-1]
V=max(V,N)
S=N*N
inf=1<<60
dp=[inf]*(S+1)
dp[N]=C[N]
for v in range(1,N+1):
    c=C[v]
    for s in range(v,S+1):
        dp[s]=min(dp[s],dp[s-v]+c)
ans=inf
for s in range(S+1):
    for v in range(1,N+1):
        c=C[v]
        if s<=V and (V-s)%v==0:
            ans=min(ans,dp[s]+(V-s)//v*c)
print(ans)
0