結果

問題 No.1701 half price
ユーザー titan23titan23
提出日時 2022-07-03 04:22:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 834 ms / 3,000 ms
コード長 467 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 77,280 KB
最終ジャッジ日時 2023-08-19 00:10:28
合計ジャッジ時間 5,693 ms
ジャッジサーバーID
(参考情報)
judge15 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,424 KB
testcase_01 AC 82 ms
76,476 KB
testcase_02 AC 147 ms
77,136 KB
testcase_03 AC 76 ms
76,336 KB
testcase_04 AC 152 ms
77,032 KB
testcase_05 AC 85 ms
76,724 KB
testcase_06 AC 810 ms
76,744 KB
testcase_07 AC 810 ms
77,280 KB
testcase_08 AC 69 ms
71,252 KB
testcase_09 AC 76 ms
76,088 KB
testcase_10 AC 69 ms
71,232 KB
testcase_11 AC 73 ms
76,328 KB
testcase_12 AC 75 ms
76,416 KB
testcase_13 AC 76 ms
76,388 KB
testcase_14 AC 80 ms
76,328 KB
testcase_15 AC 74 ms
76,284 KB
testcase_16 AC 69 ms
71,356 KB
testcase_17 AC 66 ms
71,124 KB
testcase_18 AC 67 ms
71,276 KB
testcase_19 AC 68 ms
71,348 KB
testcase_20 AC 69 ms
71,396 KB
testcase_21 AC 834 ms
76,844 KB
権限があれば一括ダウンロードができます

ソースコード

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