結果

問題 No.31 悪のミックスジュース
ユーザー masamasa
提出日時 2015-01-28 17:18:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 703 bytes
コンパイル時間 613 ms
コンパイル使用メモリ 65,396 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-05 07:23:57
合計ジャッジ時間 1,756 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int n, v, c;

	cin >> n >> v;
	vector<long long> sum(n + 1, 0);
	vector<double> cost_v(n + 1, 0.0);
	for (int i = 1; i <= n; i++) {
		cin >> c;
		sum[i] += sum[i - 1] + c;
		cost_v[i] = 1.0 * sum[i] / i;
	}

	long long ans = 0;
	ans += sum[n];
	v -= n;

	while (v > 0) {
		int limit = min(n, v);
		double min_cost = cost_v[1];
		int min_pos = 1;
		for (int i = 2; i <= limit; i++) {
			if (min_cost > cost_v[i]) {
				min_cost = cost_v[i];
				min_pos = i;
			}
		}
		ans += (long long) v / min_pos * sum[min_pos];
		v %= min_pos;
	}

	cout << ans << endl;
	return 0;
}
0