結果

問題 No.1701 half price
ユーザー ThetaTheta
提出日時 2024-03-28 18:43:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 202 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 16,532 KB
最終ジャッジ日時 2024-03-28 18:43:44
合計ジャッジ時間 6,163 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
9,856 KB
testcase_01 AC 29 ms
9,856 KB
testcase_02 AC 433 ms
9,856 KB
testcase_03 AC 29 ms
9,856 KB
testcase_04 AC 421 ms
9,856 KB
testcase_05 AC 33 ms
9,856 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます

ソースコード

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