結果

問題 No.1701 half price
ユーザー Theta
提出日時 2024-03-28 18:43:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 15,872 KB
最終ジャッジ日時 2024-09-30 14:49:14
合計ジャッジ時間 5,832 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 TLE * 1 -- * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product


def main():
    N, W = map(int, input().split())
    a = list(map(int, input().split()))
    ctr = set()
    for bit_3 in product(range(3), repeat=N):
        tmp_sum = 0
        tmp_bit_n = 0
        for idx, (bit, v) in enumerate(zip(bit_3, a)):
            match bit:
                case 0:
                    pass
                case 1:
                    tmp_sum += v
                    tmp_bit_n += 2**idx
                case 2:
                    tmp_sum += v // 2
                    tmp_bit_n += 2**idx
        if tmp_sum == W:
            ctr.add(tmp_bit_n)
    print(len(ctr))


if __name__ == "__main__":
    main()
0