結果

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

テストケース

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

ソースコード

diff #

#include <cstdio>
int a[25];

int main(){
	int n,w;
	scanf("%d%d",&n,&w);
	for(int i = 0; i < n; i++) scanf("%d",&a[i]);
	int ans = 0;
	for(int i = 1; i < (1<<n); i++){
		int s = i;
		long long sum = 0;
		for(int j = 0; j < s; j++){
			if(s%2) sum += 1ll*a[j];
			s /= 2;
		}
		int ok = 0;
		s = i;
		if(sum == w) ans++;
		for(int j = 0; j < s; j++){
			if(s%2){
				long long after = sum - a[j]/2;
				if(after == w) ans++;
			}
			s /= 2;
		}
		//ans += ok;
	}
	printf("%d\n",ans);
	return 0;
}
0