結果

問題 No.2844 Birthday Party Decoration
ユーザー titia
提出日時 2024-08-24 01:20:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-08-24 01:20:32
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

T=int(input())

for tests in range(T):
    N,X=map(int,input().split())
    C=list(map(int,input().split()))

    MAX=X

    for c in C:
        if (1<<c) & X !=0:
            continue
        k=2**c

        a=(X+k-1)//k
        if a%2==0:
            a+=1
        MAX=max(MAX,a*k)

    MIN=1<<60

    for c in C:
        if (1<<c) & X !=0:
            continue
        k=2**c

        a=X//k
        if a%2==0:
            a-=1

        if a<0:
            MIN=-1<<60
        else:
            MIN=min(MIN,a*k)

    ANS=min(MAX-X,abs(X-MIN))

    print(ANS*2)


    
0