結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 21:56:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 769 bytes |
| コンパイル時間 | 1,762 ms |
| コンパイル使用メモリ | 192,800 KB |
| 最終ジャッジ日時 | 2025-02-23 23:44:38 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int T;
cin >> T;
while(T--){
ll n, x, S = 0;
cin >> n >> x;
ll ans = 0;
for(int i = 0; i < n; i++){
int v;
cin >> v;
S |= 1ll << v;
}
S &= ~x;
if(S == 0){
cout << 0 << '\n';
continue;
}
S = 1ll << __lg(S);
ans = S - (x & (S - 1));
if(S <= x){
for(int i = 0; i < 60; i++){
if(S >> i & 1) continue;
if(S + (1ll << i) <= x) S += 1ll << i;
}
ans = min(ans, x - S);
}
cout << 2 * ans << '\n';
}
}