結果

問題 No.31 悪のミックスジュース
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-06 17:25:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 165,144 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 07:22:02
合計ジャッジ時間 2,793 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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] = {};
    int 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[20010] = {};
    for (int i = 1; i < 20000; i++) {
        dp[i] = 1e11;
    }
    for (int i = 1; i <= N; i++) {
        for (int v = 0; v < 20000 - 200; v++) {
            dp[v + i] = min(dp[v + i], dp[v] + sum[i]);
        }
    }

    ll times = max(V - 15000, 0);
    times /= best;
    cost += times * sum[best] + dp[V - times * best];

    cout << cost << endl;
}
0