結果
問題 |
No.2844 Birthday Party Decoration
|
ユーザー |
![]() |
提出日時 | 2024-08-23 21:41:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 745 bytes |
コンパイル時間 | 2,180 ms |
コンパイル使用メモリ | 195,776 KB |
最終ジャッジ日時 | 2025-02-23 23:36:59 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } void solve() { int n; long long x; cin >> n >> x; vector<int> c; bool erase_flg = false; for (int i = 0; i < n; i++) { int a; cin >> a; if (x & (1LL << a)) { erase_flg = true; x ^= (1LL << a); continue; } c.push_back(a); } if (c.empty()) { cout << 0 << endl; return; } for (int i = c.back() + 1; i <= 60; i++) { if (x & (1LL << i)) { x ^= (1LL << i); } } long long ans = (1LL << c.back()); if (erase_flg) { cout << min(2 * (x + 1), 2 * (ans - x)) << endl; } else { cout << 2 * (ans - x) << endl; } } int main() { fast_io(); int t; cin >> t; for (; t--;) { solve(); } }