結果

問題 No.31 悪のミックスジュース
ユーザー なおなお
提出日時 2014-09-29 00:41:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 95 ms / 5,000 ms
コード長 883 bytes
コンパイル時間 421 ms
コンパイル使用メモリ 61,780 KB
実行使用メモリ 11,428 KB
最終ジャッジ日時 2023-10-12 17:13:48
合計ジャッジ時間 2,395 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
11,160 KB
testcase_01 AC 82 ms
11,160 KB
testcase_02 AC 83 ms
11,160 KB
testcase_03 AC 93 ms
11,188 KB
testcase_04 AC 94 ms
11,156 KB
testcase_05 AC 94 ms
11,136 KB
testcase_06 AC 5 ms
11,136 KB
testcase_07 AC 95 ms
11,136 KB
testcase_08 AC 93 ms
11,148 KB
testcase_09 AC 93 ms
11,144 KB
testcase_10 AC 93 ms
11,160 KB
testcase_11 AC 29 ms
11,204 KB
testcase_12 AC 67 ms
11,220 KB
testcase_13 AC 5 ms
11,148 KB
testcase_14 AC 91 ms
11,204 KB
testcase_15 AC 20 ms
11,428 KB
testcase_16 AC 36 ms
11,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

ull VV[102];
ull dp[1000100];

int main(){
    int N,V,C;
    cin >> N >> V;

    REP(i,N){
        cin >> C; VV[i+1] = C;
    }
    REP(i,N) VV[i+1] += VV[i];
    V = max(0, V - N);

    dp[0] = 0;
    for(int i = 1; i < 1000100; i++){
        dp[i] = dp[i-1] + VV[1];
    }
    for(int k = 2; k <= N; k++){
        for(int i = k; i < 1000100; i++){
            dp[i] = min(dp[i], dp[i-k]+VV[k]);
        }
    }
    int t = 1;
    for(int i = 2; i <= N; i++){
        if(VV[t]*i > VV[i]*t) t = i;
    }

    int k = max(0, (V-1000000) / t);
    ull cost = 0;
    cost += k * VV[t];
    cost += dp[V - k*t];
    cost += VV[N];
    cout << cost << endl;
    return 0;
}
0