結果

問題 No.2844 Birthday Party Decoration
ユーザー Ayuna
提出日時 2024-07-14 15:30:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 994 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 74,704 KB
最終ジャッジ日時 2025-02-22 06:39:12
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
using namespace std;
//
void solve(){
int n;
long long x;
cin >> n >> x;
vector<int> c(n);
for (int &i: c) cin >> i;
vector<int> move;
for(int i: c){
if (!(x & (1ll << i))) move.push_back(i);
}
if (move.size() == 0){
cout << 0 << endl;
return;
}
long long ans = 1ll << 61;
for (int i = 0; i <= (int)move.size(); i++){
long long minus;
if (i == (int)move.size()) minus = x;
else minus = ((x >> move[i]) << move[i]) - 1ll;
if (minus < 0) continue;
long long plus = x;
for (int &j: move){
long long p = ((x >> j) + 1ll) << j;
long long m = ((x >> j) << j) - 1ll;
if (minus <= m) continue;
if (plus < p) plus = p;
}
if (ans > (plus - minus) * 2ll) ans = (plus - minus) * 2ll;
}
cout << ans << endl;
}
int main(){
int t;
cin >> t;
while(t--) solve();
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0