結果

問題 No.1701 half price
ユーザー neko_the_shadowneko_the_shadow
提出日時 2021-10-10 01:20:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 537 ms / 3,000 ms
コード長 416 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 76,820 KB
最終ジャッジ日時 2023-10-11 17:02:11
合計ジャッジ時間 4,474 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,284 KB
testcase_01 AC 78 ms
76,048 KB
testcase_02 AC 117 ms
76,616 KB
testcase_03 AC 77 ms
76,224 KB
testcase_04 AC 115 ms
76,280 KB
testcase_05 AC 85 ms
76,408 KB
testcase_06 AC 537 ms
76,760 KB
testcase_07 AC 537 ms
76,776 KB
testcase_08 AC 72 ms
71,288 KB
testcase_09 AC 77 ms
76,220 KB
testcase_10 AC 72 ms
71,116 KB
testcase_11 AC 77 ms
76,132 KB
testcase_12 AC 78 ms
76,132 KB
testcase_13 AC 79 ms
76,136 KB
testcase_14 AC 79 ms
76,128 KB
testcase_15 AC 78 ms
76,056 KB
testcase_16 AC 72 ms
71,200 KB
testcase_17 AC 72 ms
71,244 KB
testcase_18 AC 71 ms
71,272 KB
testcase_19 AC 72 ms
71,060 KB
testcase_20 AC 73 ms
71,196 KB
testcase_21 AC 523 ms
76,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

ans = set()
for bit in range(3**n):
    x = bit
    total = 0
    key = 0
    for i in range(n):
        y = x % 3
        x //= 3
        if y == 1: total += a[i]
        if y == 2: total += a[i] // 2
        if y != 0: key |= (1 << i)
    if total == w: ans.add(key)

print(len(ans))
0