結果

問題 No.1701 half price
ユーザー publflpublfl
提出日時 2021-10-08 22:01:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 10:08:39
合計ジャッジ時間 1,224 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int a;
long long int b;
int x[110];
int check[1000010];
void func(int k, int bit, long long int sum)
{
	if(k>a)
	{
		if(sum==b) check[bit] = 1;
		return;
	}
	
	func(k+1,bit,sum);
	func(k+1,bit+(1<<(k-1)),sum+x[k]/2);
	func(k+1,bit+(1<<(k-1)),sum+x[k]);
}
int main()
{
	scanf("%d%lld",&a,&b);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	func(1,0,0);
	
	int ans = 0;
	for(int i=0;i<(1<<a);i++) ans += check[i];
	printf("%d",ans);
}
0