結果

問題 No.2364 Knapsack Problem
ユーザー tailstails
提出日時 2023-06-30 21:34:56
言語 cLay
(20240104-1)
結果
AC  
実行時間 1,538 ms / 3,000 ms
コード長 375 bytes
コンパイル時間 3,367 ms
コンパイル使用メモリ 165,252 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 15:25:53
合計ジャッジ時間 8,589 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

ll@n,@m,@w,@a[n],@b[],@c[m],@d[],z=0;
vector<array<ll,3>>v;
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){
			v.push_back({x[0]|1<<i,x[1]+a[i],x[2]+b[i]});
		}
	}
	rep(i,m){
		if(!(x[0]&1<<n+i)&&x[1]-c[i]>=0){
			v.push_back({x[0]|1<<n+i,x[1]-c[i],x[2]-d[i]});
		}
	}
}
wt(z);
0