結果

問題 No.2364 Knapsack Problem
ユーザー tailstails
提出日時 2023-07-03 11:42:01
言語 cLay
(20240104-1)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 3,948 ms
コンパイル使用メモリ 165,156 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-24 08:44:29
合計ジャッジ時間 5,193 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

ll@n,@m,@w,@a[n],@b[],@c[m],@d[],z=0;
vector<array<ll,3>>v;
char u[1<<14];
v.push_back({0,0,0});
while(!v.empty()){
	auto x=v.back();
	v.pop_back();
	if(z<x[2]){
		z=x[2];
	}
	rep(i,n){
		if(!(x[0]&1<<i)&&x[1]+a[i]<=w){
			ll j=x[0]|1<<i;
			if(!u[j]++){
				v.push_back({j,x[1]+a[i],x[2]+b[i]});
			}
		}
	}
	rep(i,m){
		if(!(x[0]&1<<n+i)&&x[1]-c[i]>=0){
			ll j=x[0]|1<<n+i;
			if(!u[j]++){
				v.push_back({j,x[1]-c[i],x[2]-d[i]});
			}
		}
	}
}
wt(z);
0