結果

問題 No.1701 half price
ユーザー pengin_2000pengin_2000
提出日時 2022-09-02 09:33:25
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 64 ms / 3,000 ms
コード長 676 bytes
コンパイル時間 1,146 ms
コンパイル使用メモリ 29,056 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-09 17:58:09
合計ジャッジ時間 1,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
int main()
{
	long long int n, w;
	scanf("%lld %lld", &n, &w);
	long long int a[16];
	long long int i, j, k, l;
	for (i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	long long int ans = 0, sum, f, cnt;
	long long int ind[16];
	for (k = 1; k < (1 << n); k++)
	{
		cnt = 0;
		for (j = k, i = 0; i < n; i++, j /= 2)
		{
			if (j % 2 > 0)
			{
				ind[cnt] = i;
				cnt++;
			}
		}
		f = 0;
		for (l = 0; l < (1 << cnt); l++)
		{
			sum = 0;
			for (j = l, i = 0; i < cnt; i++, j /= 2)
			{
				if (j % 2 > 0)
					sum += a[ind[i]];
				else
					sum += a[ind[i]] / 2;
			}
			if (sum == w)
				f++;
		}
		if (f > 0)
			ans++;
	}
	printf("%lld\n", ans);
	return 0;
}
0