結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 21:28:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 89 ms / 2,000 ms |
| コード長 | 414 bytes |
| コンパイル時間 | 332 ms |
| コンパイル使用メモリ | 82,264 KB |
| 実行使用メモリ | 76,432 KB |
| 最終ジャッジ日時 | 2024-08-23 21:28:13 |
| 合計ジャッジ時間 | 1,301 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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()