結果

問題 No.1701 half price
ユーザー ThetaTheta
提出日時 2024-03-28 18:47:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 75,464 KB
最終ジャッジ日時 2024-03-28 18:47:09
合計ジャッジ時間 4,489 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,460 KB
testcase_01 AC 42 ms
59,720 KB
testcase_02 AC 109 ms
75,336 KB
testcase_03 AC 47 ms
59,720 KB
testcase_04 AC 111 ms
75,336 KB
testcase_05 AC 49 ms
64,072 KB
testcase_06 AC 696 ms
75,320 KB
testcase_07 AC 677 ms
75,320 KB
testcase_08 WA -
testcase_09 AC 43 ms
59,720 KB
testcase_10 AC 37 ms
53,460 KB
testcase_11 AC 42 ms
59,720 KB
testcase_12 AC 42 ms
59,720 KB
testcase_13 AC 42 ms
59,720 KB
testcase_14 AC 42 ms
59,720 KB
testcase_15 AC 42 ms
59,720 KB
testcase_16 AC 37 ms
53,460 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 36 ms
53,460 KB
testcase_21 AC 703 ms
75,320 KB
権限があれば一括ダウンロードができます

ソースコード

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