結果

問題 No.2844 Birthday Party Decoration
ユーザー Ayuna
提出日時 2024-07-14 16:32:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 467 bytes
コンパイル時間 434 ms
コンパイル使用メモリ 82,092 KB
実行使用メモリ 77,444 KB
最終ジャッジ日時 2024-07-14 16:32:43
合計ジャッジ時間 2,141 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    n, x = map(int, input().split())
    c = list(map(int, input().split()))
    ans = 0
    for i in c:
        if x & (1 << i):
            continue
        plus = ((x >> i) + 1) << i
        minus = ((x >> i) << i) - 1
        if (minus < 0 and ans < (plus - x) * 2):
            ans = (plus - x) * 2
        elif (minus >= 0 and ans < min(plus - x, x - minus) * 2):
            ans = min(plus - x, x - minus) * 2
    print(ans)
0