結果

問題 No.31 悪のミックスジュース
ユーザー anonyanony
提出日時 2014-09-29 00:01:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 64,552 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 19:50:38
合計ジャッジ時間 1,446 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 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 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
	int n, v;
	cin >> n >> v;
	vector<long long> c(n);
	for (int i = 0; i < n; ++i) cin >> c[i];

	partial_sum(c.begin(), c.end(), c.begin());

	const int N = 300;
	vector<long long> dp(N + 10, 1e18);
	dp[0] = 0;
	for (int i = 0; i < n; ++i){
		for (int j = 0; j < N - i; ++j){
			dp[i + 1 + j] = min(dp[i + 1 + j], dp[j] + c[i]);
		}
	}
	for (int i = N; i >= 0; --i) dp[i] = min(dp[i], dp[i + 1]);

	long long base = c.back();
	v = max(0, v - n);

	long long ans = 1e18;
	for (int i = 0; i < n; ++i){
		ans = min(ans, v / (i + 1) * c[i] + dp[v % (i + 1)]);
	}
	cout << base+ans << endl;

	return 0;
}
0