結果

問題 No.1701 half price
ユーザー H3PO4H3PO4
提出日時 2021-10-08 22:07:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 542 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 10,980 KB
実行使用メモリ 12,484 KB
最終ジャッジ日時 2023-09-30 10:20:45
合計ジャッジ時間 5,951 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
12,228 KB
testcase_01 AC 16 ms
7,992 KB
testcase_02 AC 642 ms
7,944 KB
testcase_03 AC 16 ms
7,844 KB
testcase_04 AC 600 ms
7,864 KB
testcase_05 AC 21 ms
7,832 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 #

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