結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
Ayuna
|
| 提出日時 | 2024-07-14 15:00:39 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 627 bytes |
| コンパイル時間 | 711 ms |
| コンパイル使用メモリ | 77,188 KB |
| 最終ジャッジ日時 | 2025-02-22 06:38:46 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
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);
}
reverse(move.begin(), move.end());
for (int &i: move){
long long plus = ((x >> i) + 1ll) << i;
long long minus = ((x >> i) << i) - 1ll;
if (minus < 0) cout << (plus - x) * 2ll << endl;
else cout << min(plus - x, x - minus) * 2ll << endl;
return;
}
cout << 0 << endl;
}
int main(){
int t;
cin >> t;
while(t--) solve();
}
Ayuna