結果

問題 No.1701 half price
コンテスト
ユーザー norioc
提出日時 2026-06-09 02:53:37
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 294 ms / 3,000 ms
コード長 513 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 138 ms
コンパイル使用メモリ 85,424 KB
実行使用メモリ 80,768 KB
最終ジャッジ日時 2026-06-09 02:53:40
合計ジャッジ時間 2,812 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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 0:
                b <<= 1

            case 1:
                tot += A[i]
                b = (b << 1) | 1

            case 2:
                tot += A[i] // 2
                b = (b << 1) | 1

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

ans = len(used)
print(ans)
0