結果

問題 No.31 悪のミックスジュース
ユーザー pekempeypekempey
提出日時 2015-08-28 10:42:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 969 bytes
コンパイル時間 1,184 ms
コンパイル使用メモリ 146,840 KB
実行使用メモリ 19,628 KB
最終ジャッジ日時 2023-09-25 19:00:52
合計ジャッジ時間 2,417 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) rep2 (i, 0, a)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) repr2 (i, 0, a)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;

const ll inf = 1e18;
ll dp[101][20202];

int main() {
	ll N, V;
	cin >> N >> V;
	vector<ll> C(N);	
	rep (i, N) cin >> C[i];
	partial_sum(C.begin(), C.end(), C.begin());

	if (V <= N) {
		cout << C[N - 1] << endl;
		return 0;
	}
	V -= N;

	int mini = 0;
	rep (i, N) {
		if (C[mini] * (i + 1) > C[i] * (mini + 1)) mini = i;
	}

	rep (i, 101) rep (j, 20202) dp[i][j] = inf;
	dp[0][0] = 0;

	rep2 (i, 1, N + 1) {
		rep (j, 20202) {
			dp[i][j] = dp[i - 1][j];
			if (j - i >= 0) {
				dp[i][j] = min(dp[i][j], dp[i][j - i] + C[i - 1]);
			}
		}
	}

	ll ans;
	if (V >= 20000) {
		ll x = (V - 20000) / (mini + 1);
		ans = x + dp[N][20000];
	} else {
		ans = dp[N][V];
	}
	ans += C[N - 1];
	cout << ans << endl;

	return 0;
}
0