結果

問題 No.1701 half price
ユーザー k_o_pasturek_o_pasture
提出日時 2021-10-08 22:56:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 723 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 13,156 KB
最終ジャッジ日時 2023-09-30 12:09:45
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,256 KB
testcase_01 AC 16 ms
8,220 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 17 ms
8,244 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 16 ms
8,360 KB
testcase_10 AC 16 ms
8,208 KB
testcase_11 WA -
testcase_12 AC 16 ms
8,216 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 16 ms
8,264 KB
testcase_16 AC 16 ms
8,380 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 16 ms
8,316 KB
testcase_21 AC 175 ms
11,160 KB
権限があれば一括ダウンロードができます

ソースコード

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:]:
	i = 0
	goods = []
	for bit in bits:
		if bit:
			goods.append(A[i])
		i += 1
	goods_lst.append(goods)

# print(goods_lst)

yen_lst = []
for goods in goods_lst:
	bit_lst = [[True] * len(goods) for _ in range(len(goods)+1)]
	for l in range(len(goods)):
		bit_lst[l][l] = False
	
	# print(bit_lst, goods)
	for bits in bit_lst:
		yen = 0
		for i, bit in enumerate(bits):
			if bit:
				yen += goods[i]
			else:
				yen += goods[i] // 2
		yen_lst.append(yen)

# print(yen_lst)

ans = 0
for yen in yen_lst:
	if W == yen:
		ans += 1
print(ans)
0