結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 22:51:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 1,222 bytes |
| コンパイル時間 | 930 ms |
| コンパイル使用メモリ | 97,816 KB |
| 最終ジャッジ日時 | 2025-02-24 00:10:27 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cctype>
#include <functional>
#include <cassert>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ull = unsigned long long;
using Matrix = std::vector<std::vector<ll>>;
const int inf = 1000000000;
const ll INF = 1000000000000000000;
const ll mod = 998244353;
const ull mod_hash = (1UL << 61) - 1;
const std::vector<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
const std::vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
int main(){
int T; cin >> T;
while(T--){
ll N, X; cin >> N >> X;
ll target = 0;
REP(i, N) {
ll c; cin >> c;
target += (1LL << c);
}
ll ans = 0;
ll now = 0;
REP(i, 61){
if((X >> i) & 1){
now += (1LL << i);
}
ll tmp = (1LL << 62);
if((target >> i) & 1 && !((now >> i) & 1)){
tmp = min(tmp, (1LL << i) - now);
if(now < X) tmp = min(tmp, now + 1);
ans = max(ans, 2 * tmp);
}
}
cout << ans << endl;
}
return 0;
}