結果

問題 No.31 悪のミックスジュース
ユーザー kriiikriii
提出日時 2014-12-15 01:01:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 639 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 26,992 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-12 17:14:19
合計ジャッジ時間 1,271 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>

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

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<=10000;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<=10000;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