結果

問題 No.1701 half price
ユーザー ys
提出日時 2022-03-07 02:06:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 333 ms / 3,000 ms
コード長 422 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,416 KB
最終ジャッジ日時 2024-07-21 13:48:25
合計ジャッジ時間 3,270 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(1, 1 << N):
  C = []
  res = 0
  add = 0
  for j in range(N):
    if i & 1 << j:
      res += a[j]
      C.append(j)
  if res == W:
    add = 1

  L = len(C)
  for j in range(1 << L):
    res2 = res
    for k in range(L):
      if j & 1 << k:
        res2 -= a[C[k]] // 2

    if res2 == W:
      add = 1

  ans += add
print(ans)
0