結果

問題 No.2730 Two Types Luggage
ユーザー Aging1986Aging1986
提出日時 2024-04-19 21:47:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 2,000 ms
コード長 2,668 bytes
コンパイル時間 3,015 ms
コンパイル使用メモリ 221,704 KB
実行使用メモリ 27,776 KB
最終ジャッジ日時 2024-04-19 21:47:25
合計ジャッジ時間 8,518 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 7 ms
5,376 KB
testcase_11 AC 143 ms
9,300 KB
testcase_12 AC 215 ms
27,756 KB
testcase_13 AC 116 ms
8,064 KB
testcase_14 AC 144 ms
9,344 KB
testcase_15 AC 46 ms
21,500 KB
testcase_16 AC 54 ms
5,632 KB
testcase_17 AC 184 ms
10,900 KB
testcase_18 AC 168 ms
10,328 KB
testcase_19 AC 16 ms
5,376 KB
testcase_20 AC 70 ms
6,272 KB
testcase_21 AC 131 ms
8,952 KB
testcase_22 AC 187 ms
10,996 KB
testcase_23 AC 18 ms
5,376 KB
testcase_24 AC 79 ms
6,784 KB
testcase_25 AC 141 ms
9,472 KB
testcase_26 AC 38 ms
5,376 KB
testcase_27 AC 135 ms
9,088 KB
testcase_28 AC 76 ms
6,400 KB
testcase_29 AC 165 ms
10,240 KB
testcase_30 AC 26 ms
20,548 KB
testcase_31 AC 110 ms
8,064 KB
testcase_32 AC 100 ms
7,376 KB
testcase_33 AC 211 ms
27,520 KB
testcase_34 AC 200 ms
27,392 KB
testcase_35 AC 203 ms
27,648 KB
testcase_36 AC 206 ms
27,648 KB
testcase_37 AC 214 ms
27,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma clang diagnostic push
#pragma ide diagnostic ignored "cppcoreguidelines-narrowing-conversions"
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<pdd> vpdd;
typedef vector<vd> vvd;
#define yn(ans) printf("%s\n", (ans)?"Yes":"No");
#define YN(ans) printf("%s\n", (ans)?"YES":"NO");
template<class T> bool chmax(T &a, T b) {
	if (a >= b) return false;
	a = b; return true;
}
template<class T> bool chmin(T &a, T b) {
	if (a <= b) return false;
	a = b; return true;
}
#define FOR(i, s, e, t) for ((i) = (s); (i) < (e); (i) += (t)) 
#define REP(i, e) for (int i = 0; i < (e); ++i) 
#define REP1(i, s, e) for (int i = (s); i < (e); ++i)
#define RREP(i, e) for (int i = (e); i >= 0; --i)
#define RREP1(i, e, s) for (int i = (e); i >= (s); --i)
#define all(v) v.begin(), v.end()
#define pb push_back
#define qb pop_back
#define pf push_front
#define qf pop_front
#define maxe max_element
#define mine min_element
ll inf = 1e18;
#define DEBUG printf("%d\n", __LINE__); fflush(stdout);
template<class T> void print(vector<T> &v, bool withSize = false) {
	if (withSize) cout << v.size() << endl;
	REP(i, v.size()) cout << v[i] << " "; 
	cout << endl;
}
mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());

int __FAST_IO__ = []() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);
	return 0;
}();

#define TESTS int t; cin >> t; while (t--)
#define TEST 
int main() {
    TEST {
    	int N, M; ll W;
    	cin >> N >> M >> W;
    	vll A(N), B(M), C(M);
    	REP(i, N) cin >> A[i];
    	REP(i, M) cin >> B[i];
    	REP(i, M) cin >> C[i];
    	
    	sort(all(A), greater<ll>());
    	REP1(i, 1, N) A[i] += A[i - 1];
    	vll dpB(1 << M, 0), dpC(1 << M, 0);
    	ll ans = 0;
    	REP(i, 1 << M) {
    		if (i > 0) {
    			int j = __builtin_ctz(i), ni = i ^ (1 << j);
    			dpB[i] = dpB[ni] + B[j];
    			dpC[i] = dpC[ni] + C[j];
    		}
    		if (dpB[i] <= W) {
    			int left = min((ll)N, W - dpB[i]);
    			chmax(ans, dpC[i] + (left == 0 ? 0 : A[left - 1]));
    		}
    	}
    	printf("%lld\n", ans);
    }
    
    return 0;
}
0