結果

問題 No.1701 half price
ユーザー 👑 rin204rin204
提出日時 2021-10-13 18:55:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 460 ms / 3,000 ms
コード長 578 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 81,716 KB
実行使用メモリ 75,440 KB
最終ジャッジ日時 2023-10-17 19:09:37
合計ジャッジ時間 3,180 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,416 KB
testcase_01 AC 37 ms
53,416 KB
testcase_02 AC 82 ms
72,372 KB
testcase_03 AC 38 ms
53,416 KB
testcase_04 AC 81 ms
72,372 KB
testcase_05 AC 47 ms
61,980 KB
testcase_06 AC 458 ms
75,408 KB
testcase_07 AC 330 ms
75,440 KB
testcase_08 AC 37 ms
53,416 KB
testcase_09 AC 41 ms
59,904 KB
testcase_10 AC 37 ms
53,416 KB
testcase_11 AC 38 ms
53,416 KB
testcase_12 AC 37 ms
53,416 KB
testcase_13 AC 38 ms
53,416 KB
testcase_14 AC 38 ms
53,416 KB
testcase_15 AC 42 ms
59,904 KB
testcase_16 AC 37 ms
53,416 KB
testcase_17 AC 45 ms
59,920 KB
testcase_18 AC 38 ms
53,416 KB
testcase_19 AC 43 ms
59,984 KB
testcase_20 AC 37 ms
53,416 KB
testcase_21 AC 460 ms
75,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, w = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for S in range(1, 1 << n):
    T = S
    while T != 0:
        tot = 0
        for i in range(n):
            if S >> i & 1:
                if T >> i & 1:
                    tot += A[i] // 2
                else:
                    tot += A[i]
        if tot == w:
            ans += 1
            break
        T = (T - 1) & S
    else:
        tot = 0
        for i in range(n):
            if S >> i & 1:
                tot += A[i]
        if tot == w:
            ans += 1
    
    
print(ans)
0