結果

問題 No.1701 half price
コンテスト
ユーザー lloyz
提出日時 2021-11-14 15:20:04
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 710 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 440 ms
コンパイル使用メモリ 20,832 KB
実行使用メモリ 21,760 KB
最終ジャッジ日時 2026-05-23 12:18:11
合計ジャッジ時間 7,579 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

ans_set = set()
for bit1 in range(1 << n):
    half_set = set()
    for i in range(n):
        if (bit1 >> i) & 1:
            half_set.add(i)
    for bit2 in range(1 << n):
        if (bit1 & bit2) != 0:
            continue
        if bit1 == 0 and bit2 == 0:
            continue
        not_half_set = set()
        for i in range(n):
            if (bit2 >> i) & 1:
                not_half_set.add(i)
        tmp = 0
        for i in half_set:
            tmp += A[i] // 2
        for i in not_half_set:
            tmp += A[i]
        if tmp == w:
            ans_set.add(bit1 + bit2)
print(len(ans_set))

0