結果
| 問題 | No.31 悪のミックスジュース | 
| コンテスト | |
| ユーザー |  maine_honzuki | 
| 提出日時 | 2020-05-06 18:45:51 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 833 bytes | 
| コンパイル時間 | 1,541 ms | 
| コンパイル使用メモリ | 167,660 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-03 09:03:44 | 
| 合計ジャッジ時間 | 2,180 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 17 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int N, V, C[101];
    ll cost = 0;
    cin >> N >> V;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        cost += C[i];
    }
    V -= N;
    V = max(0, V);
    ll sum[110] = {};
    ll best = 1;
    for (int i = 0; i < N; i++) {
        sum[i + 1] = sum[i] + C[i];
        if (sum[i + 1] * best < sum[best] * (i + 1))
            best = i + 1;
    }
    ll dp[30010] = {};
    for (int i = 1; i < 25000; i++) {
        dp[i] = dp[i - 1] + sum[1];
    }
    for (int i = 1; i <= N; i++) {
        for (int v = 0; v < 20000; v++) {
            dp[v + i] = min(dp[v + i], dp[v] + sum[i]);
        }
    }
    ll times = max((V - 15000) / best, 0ll);
    cost += times * sum[best] + dp[V - times * best];
    cout << cost << endl;
}
            
            
            
        