結果

問題 No.31 悪のミックスジュース
ユーザー kriiikriii
提出日時 2014-12-15 00:59:48
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 635 bytes
コンパイル時間 160 ms
コンパイル使用メモリ 27,068 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 14:34:22
合計ジャッジ時間 1,396 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int N; long long V,C[101],D[1001];

int main()
{
	scanf ("%d %lld",&N,&V);
	for (int i=1;i<=N;i++) scanf ("%lld",&C[i]), C[i] += C[i-1];

	int x = 1;
	for (int i=2;i<=N;i++) if (C[x] * i > C[i] * x) x = i;
	for (int i=1;i<=1000;i++){
		D[i] = 1e18;
		for (int j=1;j<=N;j++) if (i >= j){
			if (D[i] > D[i-j] + C[j])
				D[i] = D[i-j] + C[j];
		}
	}

	long long ans = 1e18;
	V -= N;
	if (V < 0) ans = C[N];
	for (int i=0;i<=1000;i++) if (i <= V){
		int r = (V - i + x - 1) / x;
		long long w = C[N] + D[i] + C[x] * r;
		if (ans > w)
			ans = w;
	}
	printf ("%lld\n",ans);

	return 0;
}
0