結果

問題 No.2844 Birthday Party Decoration
コンテスト
ユーザー Shirotsume
提出日時 2024-08-23 22:26:31
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 759 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 82 ms
コンパイル使用メモリ 64,484 KB
実行使用メモリ 60,560 KB
最終ジャッジ日時 2026-11-01 19:48:22
合計ジャッジ時間 1,663 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import gcd
import sys, time, random
from collections import deque, Counter, defaultdict
def debug(*x):print('debug:',*x, file=sys.stderr)
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1

def solve():
    n, x = mi()
    c = li()
    maxc = -1
    for i in range(n):
        if not (1 & (x >> c[i])):
            maxc = max(maxc, c[i])
    if maxc == -1:
        print(0)
        return
    else:
        cost = inf
        if x > (1 << (maxc + 1)):
            cost = (x % (1 << (maxc + 1)) + 1)
        cost = min(cost, (x | ((1 << (maxc + 1)) - 1)) - (1 << maxc) + 1 - x)
        print(2 * cost)
            
for _ in range(ii()):
    solve()
0