結果
問題 | No.1701 half price |
ユーザー |
![]() |
提出日時 | 2021-10-08 23:08:49 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 568 bytes |
コンパイル時間 | 704 ms |
コンパイル使用メモリ | 82,268 KB |
実行使用メモリ | 82,092 KB |
最終ジャッジ日時 | 2024-07-23 06:41:32 |
合計ジャッジ時間 | 4,326 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 WA * 5 |
ソースコード
from itertools import product n, w = map(int, input().split()) a = list(map(int, input().split())) if w == 0: zero = a.count(0) ans = 2 ** zero - 1 print(ans) exit() b = [i // 2 for i in a] ans = 0 it = [] 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 it.append(tmp) for i in it: l = [] for j in range(len(i)): l.append([a[j], b[j]]) st = [] for k in product(*l): k = sorted(k) if sum(k) == w and k not in st: st.append(k) ans += 1 print(ans)