結果
| 問題 | No.2844 Birthday Party Decoration |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 22:26:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 77 ms / 2,000 ms |
| コード長 | 759 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 82,268 KB |
| 実行使用メモリ | 77,536 KB |
| 最終ジャッジ日時 | 2024-08-23 22:26:33 |
| 合計ジャッジ時間 | 1,302 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
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()