結果

問題 No.1701 half price
ユーザー mesame3993mesame3993
提出日時 2021-10-08 23:52:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 530 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-09-30 14:19:45
合計ジャッジ時間 5,044 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,040 KB
testcase_01 AC 15 ms
8,144 KB
testcase_02 AC 160 ms
8,164 KB
testcase_03 AC 15 ms
8,248 KB
testcase_04 AC 140 ms
8,264 KB
testcase_05 AC 17 ms
8,148 KB
testcase_06 AC 1,269 ms
8,220 KB
testcase_07 WA -
testcase_08 AC 16 ms
8,124 KB
testcase_09 AC 16 ms
8,248 KB
testcase_10 AC 16 ms
8,224 KB
testcase_11 AC 16 ms
8,292 KB
testcase_12 AC 16 ms
8,044 KB
testcase_13 AC 17 ms
8,220 KB
testcase_14 AC 16 ms
8,172 KB
testcase_15 AC 16 ms
8,300 KB
testcase_16 AC 16 ms
8,228 KB
testcase_17 AC 16 ms
8,224 KB
testcase_18 AC 16 ms
8,112 KB
testcase_19 AC 17 ms
8,276 KB
testcase_20 AC 16 ms
8,168 KB
testcase_21 AC 985 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
n, w = map(int, input().split())
a = list(map(int, input().split()))
b = [i // 2 for i in a]
ans = 0
items = [i for i in range(n)]
if w == 0:
	zero = a.count(0)
	print(2**zero - 1)
	exit()
for bits in product([0, 1], repeat=n):
	tmp = [x for x, bit in zip(items, bits) if bit == 1]
	if tmp == []:
		continue
	l, l_2 = [], []
	for j in range(len(tmp)):
		l.append([a[tmp[j]], b[tmp[j]]])
	for k in product(*l):
		k = sorted(k)
		if sum(k) == w and k not in l_2:
			l_2.append(k)
			ans += 1
print(ans)
0