結果

問題 No.2844 Birthday Party Decoration
ユーザー 👑 rin204
提出日時 2024-08-23 21:28:12
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 65 ms / 2,000 ms
+ 268µs
コード長 414 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 86 ms
コンパイル使用メモリ 64,572 KB
実行使用メモリ 59,168 KB
最終ジャッジ日時 2026-11-01 19:46:47
合計ジャッジ時間 1,736 ms
ジャッジサーバーID
(参考情報)
judge7_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
    n, x = map(int, input().split())
    C = list(map(int, input().split()))
    while C and (x >> C[-1]) & 1:
        C.pop()

    if not C:
        print(0)
        return

    c = C[-1]
    if x < (1 << c):
        ans = (1 << c) - x
        print(2 * ans)
        return

    t = x & ((1 << c) - 1)
    ans = min(t + 1, (1 << c) - t)
    print(2 * ans)


for _ in range(int(input())):
    solve()
0