結果

問題 No.1701 half price
ユーザー k_o_pasturek_o_pasture
提出日時 2021-10-08 23:24:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 715 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 16,732 KB
最終ジャッジ日時 2023-09-30 13:23:51
合計ジャッジ時間 5,704 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,320 KB
testcase_01 AC 16 ms
8,340 KB
testcase_02 AC 398 ms
9,580 KB
testcase_03 AC 16 ms
8,344 KB
testcase_04 AC 365 ms
9,536 KB
testcase_05 AC 20 ms
8,256 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

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