結果

問題 No.31 悪のミックスジュース
ユーザー やまぞうやまぞう
提出日時 2015-03-10 23:57:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 778 ms
コンパイル使用メモリ 57,548 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-06 23:04:30
合計ジャッジ時間 1,637 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

#define MAX_N 100

int N;
ll T;
ll C[MAX_N];

void input(istream& in)
{
	in >> N >> T;
	for (int i = 0; i < N; i++) in >> C[i];
}

ll resolve()
{
	ll V[MAX_N];
	for (int i = 0; i < N; i++) {
		V[i] = 1;
	}
	if (T > N) {
		T -= N;

		int min_index = 0;
		ll min_value = C[0];
		for (int i = 1; i < N; i++) {
			if (C[i] < min_value) {
				min_index = i;
				min_value = C[i];
			}
		}

		ll v = T / (min_index + 1);
		for (int i = 0; i <= min_index; i++) {
			V[i] += v;
		}
		T -= v * (min_index + 1);

		if (T > 0) {
			for (int i = 0; i < T; i++) {
				V[i]++;
			}
		}
	}
	ll cost = 0;
	for (int i = 0; i < N; i++) {
		cost += C[i] * V[i];
	}
	return cost;
}

int main(int argc, char **argv)
{
	input(cin);
	cout << resolve() << endl;
	return 0;
}
0