結果

問題 No.2730 Two Types Luggage
ユーザー 赤信号赤信号
提出日時 2024-05-03 10:22:52
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,061 bytes
コンパイル時間 4,142 ms
コンパイル使用メモリ 261,232 KB
実行使用メモリ 814,592 KB
最終ジャッジ日時 2024-05-03 10:23:04
合計ジャッジ時間 8,405 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 6 ms
6,940 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")

#ifdef LOCAL
#include "algo/debug_ver3.hpp"
#else
#define debug(...)
#define debugArr(...)
#endif

#include <bits/stdc++.h>

using namespace std;

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, m;
	long long w;
	cin >> n >> m >> w;

	vector<long long> a(n), b(m), c(m);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < m; ++i) cin >> b[i];
	for (int i = 0; i < m; ++i) cin >> c[i];

	vector<vector<long long>> dp(n + 1, vector<long long>(n + 1));
	for (int i = 0; i < n; ++i) for (int j = 0; j <= n; ++j) {
		if (j + 1 <= n) dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);
		if (j + 1 <= n) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i]);
		dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
	}

	long long res = 0;
	for (int bit = 0; bit < 1 << m; ++bit) {
		long long weight = 0, value = 0;
		for (int i = 0; i < m; ++i) if (bit & 1 << i) weight += b[i], value += c[i];
		if (weight > w) continue;

		res = max(res, value + dp[n][min(w - weight, (long long)(n))]);
	}

	cout << res << '\n';
}
0