結果

問題 No.1701 half price
ユーザー tobusakana
提出日時 2022-12-03 13:45:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 75,860 KB
最終ジャッジ日時 2024-10-10 16:18:04
合計ジャッジ時間 2,313 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N,W = map(int,input().split())
A = list(map(lambda x:int(x) // 2,input().split()))

ans = 0
for status in range(1 << N):
    items = []
    for i in range(N):
        if (status >> i) & 1:
            items.append(A[i])
    rest = W - sum(items)
    if rest < 0:
        continue
    if rest == 0:
        ans += 1
        continue
    # itemsから幾つかを選んでrestに出来るか
    M = len(items)
    for bits in range(1 << M):
        val = 0
        for i in range(N):
            if (bits >> i) & 1:
                val += items[i]
                if val >= rest:
                    break
        if val == rest:
            ans += 1
            break
                
print(ans)
0