結果

問題 No.31 悪のミックスジュース
ユーザー koyoprokoyopro
提出日時 2015-09-29 14:15:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,491 bytes
コンパイル時間 555 ms
コンパイル使用メモリ 73,872 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 23:45:47
合計ジャッジ時間 1,455 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <math.h>
#include <vector>
#include <array>
#include <algorithm>
#include <queue>
#include <numeric>
#include <map>
#include <set>
#include <bitset>

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define SUM(a) accumulate(ALL(a), 0)
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

/*================================*/
int N,V;
int C[111];
double AVE[111];

signed main()
{
    cin >> N >> V;
    int cost = 0;
    REP(i,N) {
        cin >> C[i];
        // 最低1リットルずつは買う
        cost += C[i];
        V -= 1;
        AVE[i] = 1.0 * cost / (i+1);
    }
    while (V > 0) {
        int v = min(V, N);
        double minave = 1e15;
        int mini = 1e15;
        REP(i,v) {
            if (AVE[i] <= minave) {
                minave = AVE[i];
                mini = i;
            }
        }
        int a = V / (mini + 1);
        int sumc = 0;
        REP(i,mini+1) sumc += C[i];
        cost += a * sumc;

        V %= (mini + 1);
    }
    
    cout << cost << endl;
    
    return 0;
}
0