結果

問題 No.31 悪のミックスジュース
ユーザー atn112323atn112323
提出日時 2016-05-06 23:07:39
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 786 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 58,724 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 17:19:19
合計ジャッジ時間 1,147 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <iostream>

using namespace std;

const long long INF = 1000000000000000001l;

int N, V;
long long C[100];
long long cost[10101];

int main() {
	cin >> N >> V;
	long long res = 0;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		res += C[i];
		if (i > 0) {
			C[i] += C[i - 1];
		}
	}
	V -= N;
	for (int c = 0; c <= 10100; c++) {
		cost[c] = INF;
	}
	cost[0] = 0;
	for (int c = 0; c <= 10100; c++) {
		for (int i = 0; i < N; i++) {
			int cc = c + i + 1;
			if (cc <= 10100) {
				cost[cc] = min(cost[cc], cost[c] + C[i]);
			}
		}
	}
	int v = 0;
	for (int i = 1; i < N; i++) {
		if (C[i] * (v + 1) < C[v] * (i + 1)) {
			v = i;
		}
	}
	int n = max(0, (V - 10000) / (v + 1));
	V -= n * (v + 1);
	res += n * C[v] + cost[V];
	cout << res << endl;
	return 0;
}
0