結果

問題 No.1701 half price
ユーザー mesame3993
提出日時 2021-10-08 23:49:50
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 337 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-23 08:18:50
合計ジャッジ時間 6,449 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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)]
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