結果
問題 |
No.1701 half price
|
ユーザー |
![]() |
提出日時 | 2021-10-08 22:46:23 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 599 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 82,796 KB |
実行使用メモリ | 76,372 KB |
最終ジャッジ日時 | 2024-07-23 05:53:33 |
合計ジャッジ時間 | 2,861 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 WA * 4 |
ソースコード
N,W = map(int,input().split()) A = list(map(int, input().split())) ans = 0 for i in range(2 ** N): bag = [] total = 0 for j in range(N): # このループが一番のポイント if ((i >> j) & 1): # 順に右にシフトさせ最下位bitのチェックを行う bag.append(A[j]) total += A[j] ok = total==W for j in range(2 ** len(bag)): temp = 0 for k in range(len(bag)): if ((j >> k) & 1): temp+=bag[k]//2 ok = ok or (total - temp == W) if ok: ans+=1 print print(ans)