結果

問題 No.1701 half price
コンテスト
ユーザー norioc
提出日時 2026-06-09 02:54:56
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 272 ms / 3,000 ms
+ 370µs
コード長 438 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 80 ms
コンパイル使用メモリ 64,964 KB
実行使用メモリ 59,264 KB
最終ジャッジ日時 2026-10-15 04:09:18
合計ジャッジ時間 3,458 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from itertools import product

N, W = map(int, input().split())
A = list(map(int, input().split()))

used = set()
for xs in product([0, 1, 2], repeat=N):
    tot = 0
    b = 0
    for i, x in enumerate(xs):
        match x:
            case 1:
                tot += A[i]
            case 2:
                tot += A[i] // 2

        b = (b << 1) | int(bool(x))

    if tot == W and b > 0:
        used.add(b)

ans = len(used)
print(ans)
0