結果

問題 No.1701 half price
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-10-08 22:13:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 325 ms / 3,000 ms
コード長 388 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 86,352 KB
実行使用メモリ 76,884 KB
最終ジャッジ日時 2023-09-30 10:31:50
合計ジャッジ時間 3,818 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,832 KB
testcase_01 AC 75 ms
71,136 KB
testcase_02 AC 108 ms
76,880 KB
testcase_03 AC 76 ms
70,868 KB
testcase_04 AC 108 ms
76,524 KB
testcase_05 AC 85 ms
76,076 KB
testcase_06 AC 281 ms
76,884 KB
testcase_07 AC 263 ms
76,600 KB
testcase_08 AC 76 ms
71,084 KB
testcase_09 AC 76 ms
70,984 KB
testcase_10 AC 76 ms
71,040 KB
testcase_11 AC 76 ms
70,788 KB
testcase_12 AC 76 ms
71,156 KB
testcase_13 AC 76 ms
70,864 KB
testcase_14 AC 75 ms
70,956 KB
testcase_15 AC 75 ms
71,136 KB
testcase_16 AC 74 ms
70,936 KB
testcase_17 AC 90 ms
75,964 KB
testcase_18 AC 77 ms
70,792 KB
testcase_19 AC 81 ms
75,532 KB
testcase_20 AC 76 ms
71,064 KB
testcase_21 AC 325 ms
76,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for b in range(1, 1 << n):
	cnt = 0
	l = []
	for i in range(n):
		if b >> i & 1:
			cnt += a[i]
			l.append(a[i])
	f = False
	if cnt == w: f = True
	for b2 in range(1 << len(l)):
		cnt2 = cnt
		for i in range(len(l)):
			if b2 >> i & 1:
				cnt2 -= l[i] // 2
		if cnt2 == w: f = True; break
	ans += f
print(ans)
0