結果

問題 No.1701 half price
ユーザー lloyzlloyz
提出日時 2021-11-14 15:19:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 739 ms / 3,000 ms
コード長 683 bytes
コンパイル時間 1,299 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 77,792 KB
最終ジャッジ日時 2023-08-19 22:05:16
合計ジャッジ時間 6,483 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,156 KB
testcase_01 AC 78 ms
75,544 KB
testcase_02 AC 172 ms
77,268 KB
testcase_03 AC 73 ms
75,732 KB
testcase_04 AC 167 ms
77,220 KB
testcase_05 AC 90 ms
76,588 KB
testcase_06 AC 675 ms
77,384 KB
testcase_07 AC 739 ms
77,528 KB
testcase_08 AC 69 ms
71,348 KB
testcase_09 AC 72 ms
75,724 KB
testcase_10 AC 68 ms
71,256 KB
testcase_11 AC 73 ms
75,644 KB
testcase_12 AC 72 ms
75,516 KB
testcase_13 AC 73 ms
75,656 KB
testcase_14 AC 72 ms
75,516 KB
testcase_15 AC 72 ms
75,672 KB
testcase_16 AC 69 ms
71,280 KB
testcase_17 AC 283 ms
77,792 KB
testcase_18 AC 89 ms
76,448 KB
testcase_19 AC 94 ms
76,528 KB
testcase_20 AC 68 ms
71,192 KB
testcase_21 AC 662 ms
77,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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