結果

問題 No.1701 half price
ユーザー k_o_pasture
提出日時 2021-10-08 23:24:59
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 715 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,660 KB
最終ジャッジ日時 2024-07-23 07:25:37
合計ジャッジ時間 5,831 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
N,W = map(int,input().split())
A = list(map(int,input().split()))
bit_lst = list(product([False, True], repeat=N))
goods_lst = []
for bits in bit_lst[1:]:
	goods = []
	for i, bit in enumerate(bits):
		if bit:
			goods.append(A[i])
	goods_lst.append(goods)

# print(goods_lst)

receipt = []
for goods, bits in zip(goods_lst, bit_lst[1:]):
	even_lst = list(product([False, True], repeat=len(goods)))
	# for l in range(len(goods)):
	# 	even_lst[l][l] = False
	
	# print(even_lst, goods)
	for evens in even_lst:
		yen = 0
		for i, even in enumerate(evens):
			if even:
				yen += goods[i]
			else:
				yen += goods[i] // 2
		if W == yen:
			receipt.append(bits)

	
print(len(set(receipt)))
0