結果
問題 | No.1701 half price |
ユーザー | k_o_pasture |
提出日時 | 2021-10-08 23:28:39 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 457 ms / 3,000 ms |
コード長 | 772 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 86,988 KB |
実行使用メモリ | 101,380 KB |
最終ジャッジ日時 | 2023-09-30 13:31:09 |
合計ジャッジ時間 | 4,370 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,376 KB |
testcase_01 | AC | 72 ms
71,288 KB |
testcase_02 | AC | 146 ms
77,992 KB |
testcase_03 | AC | 70 ms
71,260 KB |
testcase_04 | AC | 125 ms
78,044 KB |
testcase_05 | AC | 77 ms
76,252 KB |
testcase_06 | AC | 452 ms
84,040 KB |
testcase_07 | AC | 457 ms
85,668 KB |
testcase_08 | AC | 70 ms
71,480 KB |
testcase_09 | AC | 72 ms
71,668 KB |
testcase_10 | AC | 70 ms
71,552 KB |
testcase_11 | AC | 70 ms
71,676 KB |
testcase_12 | AC | 68 ms
71,616 KB |
testcase_13 | AC | 71 ms
71,680 KB |
testcase_14 | AC | 68 ms
71,636 KB |
testcase_15 | AC | 72 ms
71,484 KB |
testcase_16 | AC | 69 ms
71,380 KB |
testcase_17 | AC | 302 ms
101,380 KB |
testcase_18 | AC | 83 ms
76,572 KB |
testcase_19 | AC | 89 ms
76,904 KB |
testcase_20 | AC | 70 ms
71,404 KB |
testcase_21 | AC | 451 ms
84,244 KB |
ソースコード
from itertools import product import sys def main(): input = sys.stdin.readline 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))) # 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))) if __name__ == '__main__': main()