結果

問題 No.1701 half price
ユーザー titan23
提出日時 2022-07-03 04:22:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 833 ms / 3,000 ms
コード長 467 bytes
コンパイル時間 403 ms
コンパイル使用メモリ 81,408 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2024-11-28 12:04:42
合計ジャッジ時間 4,627 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()

#  -----------------------  #

n, w = map(int, input().split())
A = list(map(int, input().split()))

if w == 0:
  exit(print(2**A.count(0)-1))

ans = set()
for i in range(3**n):
  tmp = 0
  buy = set()
  for j in range(n):
    if i%3 == 0:
      tmp += A[j]
      buy.add(j)
    elif i % 3 == 1:
      tmp += A[j] // 2
      buy.add(j)
    i //= 3

  if tmp == w:
    ans.add(frozenset(buy))

print(len(ans))
0