結果

問題 No.31 悪のミックスジュース
ユーザー mamekinmamekin
提出日時 2015-01-12 18:31:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 861 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 90,808 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 05:06:28
合計ジャッジ時間 1,861 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, v;
    cin >> n >> v;
    vector<long long> c(n), sum(n+1, 0);
    for(int i=0; i<n; ++i){
        cin >> c[i];
        sum[i+1] = sum[i] + c[i];
    }

    int m = v - n;
    if(m <= 0){
        cout << sum[n] << endl;
        return 0;
    }

    long long ret = LLONG_MAX;
    for(int i=1; i<=n; ++i){
        int a = m / i;
        int b = m % i;
        ret = min(ret, sum[n] + sum[i] * a + sum[b]);
    }
    cout << ret << endl;

    return 0;
}
0