結果

問題 No.2730 Two Types Luggage
ユーザー AwashAmityOakAwashAmityOak
提出日時 2024-04-19 22:23:36
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 550 ms / 2,000 ms
コード長 1,781 bytes
コンパイル時間 6,049 ms
コンパイル使用メモリ 339,032 KB
実行使用メモリ 18,944 KB
最終ジャッジ日時 2024-04-19 22:24:05
合計ジャッジ時間 17,566 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 16 ms
5,376 KB
testcase_11 AC 348 ms
14,848 KB
testcase_12 AC 491 ms
18,776 KB
testcase_13 AC 314 ms
12,416 KB
testcase_14 AC 344 ms
14,848 KB
testcase_15 AC 91 ms
6,272 KB
testcase_16 AC 129 ms
7,552 KB
testcase_17 AC 447 ms
18,176 KB
testcase_18 AC 443 ms
16,824 KB
testcase_19 AC 37 ms
5,376 KB
testcase_20 AC 164 ms
8,704 KB
testcase_21 AC 348 ms
14,216 KB
testcase_22 AC 490 ms
18,560 KB
testcase_23 AC 47 ms
5,376 KB
testcase_24 AC 199 ms
9,728 KB
testcase_25 AC 353 ms
14,976 KB
testcase_26 AC 97 ms
6,528 KB
testcase_27 AC 325 ms
14,148 KB
testcase_28 AC 179 ms
9,216 KB
testcase_29 AC 417 ms
16,992 KB
testcase_30 AC 112 ms
5,376 KB
testcase_31 AC 264 ms
12,312 KB
testcase_32 AC 237 ms
11,264 KB
testcase_33 AC 550 ms
18,816 KB
testcase_34 AC 545 ms
18,944 KB
testcase_35 AC 524 ms
18,816 KB
testcase_36 AC 541 ms
18,944 KB
testcase_37 AC 532 ms
18,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
typedef long long ll;
typedef long double ld;
#define int ll
#define OVERLOAD_REP(_1, _2, _3, name, ...) name
#define REP2(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define REP1(i, n) REP2(i, 0, n)
#define rep(...) OVERLOAD_REP(__VA_ARGS__, REP2, REP1)(__VA_ARGS__)
#define RREP2(i, l, r) for (int i = (int)(l)-1; i >= (int)(r); i--)
#define RREP1(i, n) RREP2(i, n, 0)
#define rrep(...) OVERLOAD_REP(__VA_ARGS__, RREP2, RREP1)(__VA_ARGS__)
#define all(...) begin(__VA_ARGS__), end(__VA_ARGS__)
#define rall(...) rbegin(__VA_ARGS__), rend(__VA_ARGS__)
#define debug(x) cerr << #x << ": " << (x) << endl
#define pb push_back
#define mp make_pair
#define mt make_tuple
const int INF = 4e18;
const int MOD = 1e9 + 7;
const int MOD2 = 998244353;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<class... T> void input(T&... args) { ((cin >> args), ...); }
template<class... T> void print(T... args) { ((cout << args << " "), ...); }
template<class... T> void println(T... args) { print(args...); cout << endl; }

signed main() {
	int N, M, W;
	input(N, M, W);
	
	vector<int> A(N);
	rep(i, N) input(A[i]);
	vector<int> B(M);
	rep(i, M) input(B[i]);
	vector<int> C(M);
	rep(i, M) input(C[i]);
	
	sort(rall(A));
	vector<int> A_acc(N+1);
	rep(i, N) A_acc[i+1] = A_acc[i] + A[i];
	
	int ans = 0;
	rep(i, 1 << M) {
		int weight = 0;
		int value = 0;
		rep(j, M) {
			if (i >> j & 1) {
				weight += B[j];
				value += C[j];
				if (W < weight) break;
			}
		}
		if (W < weight) break;
		chmax(ans, value + A_acc[min(W - weight, N)]);
	}
	println(ans);
}
0