結果

問題 No.1701 half price
ユーザー ThetaTheta
提出日時 2024-03-28 18:50:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 885 ms / 3,000 ms
コード長 739 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 75,764 KB
最終ジャッジ日時 2024-03-28 18:51:00
合計ジャッジ時間 5,173 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 42 ms
59,848 KB
testcase_02 AC 129 ms
75,492 KB
testcase_03 AC 41 ms
59,848 KB
testcase_04 AC 132 ms
75,492 KB
testcase_05 AC 53 ms
66,408 KB
testcase_06 AC 857 ms
75,608 KB
testcase_07 AC 885 ms
75,736 KB
testcase_08 AC 36 ms
53,460 KB
testcase_09 AC 42 ms
59,848 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 41 ms
59,848 KB
testcase_12 AC 41 ms
59,848 KB
testcase_13 AC 41 ms
59,848 KB
testcase_14 AC 42 ms
59,848 KB
testcase_15 AC 42 ms
59,848 KB
testcase_16 AC 36 ms
53,460 KB
testcase_17 AC 293 ms
75,764 KB
testcase_18 AC 55 ms
66,408 KB
testcase_19 AC 55 ms
70,516 KB
testcase_20 AC 37 ms
53,460 KB
testcase_21 AC 849 ms
75,608 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):
        if bit_3[0] == 0 and len(set(bit_3)) == 1:
            continue
        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