結果

問題 No.1701 half price
ユーザー Takuya Noguchi
提出日時 2021-10-19 22:02:13
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 379 ms
コンパイル使用メモリ 82,068 KB
実行使用メモリ 76,836 KB
最終ジャッジ日時 2024-09-20 06:26:09
合計ジャッジ時間 7,235 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

N, W = map(int, input().split())
a = list(map(int, input().split()))
answer = set()

for n in range(3**N):
    bit_str = base10to(n, 3).rjust(N, '0')

    sum, key = 0, 0
    for i, bit in enumerate(bit_str):
        if bit == '0':
            continue

        if bit == '1':
            sum += a[i]
        else:
            sum += a[i] // 2
        key += (1 << i)

    if sum == W:
        answer.add(key)

print(len(answer))
0