結果
| 問題 | No.2844 Birthday Party Decoration |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 21:28:12 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 79 ms / 2,000 ms |
| コード長 | 414 bytes |
| 記録 | |
| コンパイル時間 | 587 ms |
| コンパイル使用メモリ | 85,120 KB |
| 実行使用メモリ | 80,896 KB |
| 最終ジャッジ日時 | 2026-04-03 21:54:50 |
| 合計ジャッジ時間 | 1,325 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
def solve():
n, x = map(int, input().split())
C = list(map(int, input().split()))
while C and (x >> C[-1]) & 1:
C.pop()
if not C:
print(0)
return
c = C[-1]
if x < (1 << c):
ans = (1 << c) - x
print(2 * ans)
return
t = x & ((1 << c) - 1)
ans = min(t + 1, (1 << c) - t)
print(2 * ans)
for _ in range(int(input())):
solve()