結果

問題 No.1701 half price
ユーザー H3PO4H3PO4
提出日時 2021-10-08 22:07:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 458 ms / 3,000 ms
コード長 542 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 86,628 KB
実行使用メモリ 76,492 KB
最終ジャッジ日時 2023-09-30 10:21:27
合計ジャッジ時間 4,313 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,568 KB
testcase_01 AC 75 ms
70,756 KB
testcase_02 AC 112 ms
75,972 KB
testcase_03 AC 76 ms
70,956 KB
testcase_04 AC 111 ms
76,056 KB
testcase_05 AC 85 ms
75,984 KB
testcase_06 AC 455 ms
76,380 KB
testcase_07 AC 352 ms
76,396 KB
testcase_08 AC 76 ms
70,848 KB
testcase_09 AC 80 ms
75,924 KB
testcase_10 AC 75 ms
70,852 KB
testcase_11 AC 77 ms
70,652 KB
testcase_12 AC 76 ms
70,916 KB
testcase_13 AC 76 ms
70,964 KB
testcase_14 AC 75 ms
70,436 KB
testcase_15 AC 79 ms
75,732 KB
testcase_16 AC 76 ms
70,868 KB
testcase_17 AC 81 ms
75,984 KB
testcase_18 AC 75 ms
70,580 KB
testcase_19 AC 81 ms
75,916 KB
testcase_20 AC 77 ms
70,644 KB
testcase_21 AC 458 ms
76,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, W = map(int, input().split())
A = tuple(map(int, input().split()))

ans = 0
for b in range(1, 1 << N):
    # 別途c = 0のとき
    s = 0
    for i in range(N):
        if (b >> i) & 1:
            s += A[i]
    if s == W:
        ans += 1
        continue
    c = b
    while c:
        s = 0
        for i in range(N):
            if (c >> i) & 1:
                s += A[i] // 2
            elif (b >> i) & 1:
                s += A[i]
        if s == W:
            ans += 1
            break
        c -= 1
        c &= b
print(ans)
0