結果

問題 No.1701 half price
ユーザー Drice27149
提出日時 2021-10-08 22:08:17
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 497 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 32,000 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-23 04:28:31
合計ジャッジ時間 1,010 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 13
権限があれば一括ダウンロードができます

ソースコード

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