結果

問題 No.2844 Birthday Party Decoration
コンテスト
ユーザー sasa8uyauya
提出日時 2024-08-24 00:35:54
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 96 ms / 2,000 ms
+ 363µs
コード長 315 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 274 ms
コンパイル使用メモリ 96,108 KB
実行使用メモリ 84,352 KB
最終ジャッジ日時 2026-08-25 04:42:48
合計ジャッジ時間 1,812 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

T=int(input())
for _ in range(T):
  n,x=map(int,input().split())
  c=list(map(int,input().split()))
  for i in reversed(range(n)):
    if (x>>c[i])&1==0:
      r=((x>>c[i])+1)<<c[i]
      if x<(1<<c[i]):
        print((r-x)*2)
      else:
        print(min(r-x,x-(r-(1<<c[i])-1))*2)
      break
  else:
    print(0)
0