結果

問題 No.1701 half price
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2021-10-19 22:11:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,778 ms / 3,000 ms
コード長 566 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 81,684 KB
実行使用メモリ 76,452 KB
最終ジャッジ日時 2023-10-20 10:52:15
合計ジャッジ時間 7,894 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,532 KB
testcase_01 AC 47 ms
62,404 KB
testcase_02 AC 256 ms
76,216 KB
testcase_03 AC 48 ms
62,424 KB
testcase_04 AC 255 ms
76,216 KB
testcase_05 AC 70 ms
73,236 KB
testcase_06 AC 1,778 ms
76,384 KB
testcase_07 AC 1,652 ms
76,384 KB
testcase_08 AC 37 ms
53,532 KB
testcase_09 AC 49 ms
62,404 KB
testcase_10 AC 37 ms
53,532 KB
testcase_11 AC 48 ms
62,404 KB
testcase_12 AC 51 ms
62,404 KB
testcase_13 AC 47 ms
62,404 KB
testcase_14 AC 47 ms
62,404 KB
testcase_15 AC 47 ms
62,404 KB
testcase_16 AC 36 ms
53,532 KB
testcase_17 AC 530 ms
76,316 KB
testcase_18 AC 69 ms
72,720 KB
testcase_19 AC 87 ms
76,036 KB
testcase_20 AC 37 ms
53,532 KB
testcase_21 AC 1,641 ms
76,452 KB
権限があれば一括ダウンロードができます

ソースコード

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):
    flag_str = base10to(n, 3).rjust(N, '0')
    flag_str

    sum, key = 0, 0
    for i, flag in enumerate(flag_str):
        if flag == '1':
            sum += a[i]
            key += (1 << i)
        elif flag == '2':
            sum += a[i] // 2
            key += (1 << i)

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

print(len(answer) - (W == 0))
0