結果

問題 No.1701 half price
ユーザー 👑 rin204
提出日時 2021-10-13 18:55:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 390 ms / 3,000 ms
コード長 578 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 76,112 KB
最終ジャッジ日時 2024-09-17 16:20:52
合計ジャッジ時間 2,545 ms
ジャッジサーバーID
(参考情報)
judge4 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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