結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
Andrew8128
|
| 提出日時 | 2024-08-23 21:26:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,151 bytes |
| コンパイル時間 | 4,753 ms |
| コンパイル使用メモリ | 308,328 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-08-23 21:26:22 |
| 合計ジャッジ時間 | 5,181 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
// 441_C.cpp 2024/08/23 21:08:30
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353, mod1 = 1000000007, inf = 1070000000;
const ll linf = 4610000000000000000;
#define REP(i,x,y) for (auto i = (x); i < (y); i++)
#define RREP(i,x,y) for (auto i = (y) - 1; (x) <= i; i--)
#define ALL(x) (x).begin(), (x).end()
template<class T> bool inr(const T &l, const T &x, const T &r){return (l<=x && x<r);}
template<class T> bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} else return 0;}
template<class T> bool chmin(T &a, const T &b){if(b < a){a = b; return 1;} else return 0;}
#include <atcoder/all>
using namespace atcoder;
#pragma GCC optimize("O3")
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while(T--){
int N;
ll X;
cin >> N >> X;
vector<int> c(N);
REP(i,0,N)cin >> c[i];
ll ans = 0;
RREP(i,0,N){
if((1LL<<c[i])&X)continue;
if(X < (1LL<<c[i])){
ans = ((1LL<<c[i])-X)*2;
}else{
ll y = X % (1LL<<c[i]);
ans = min((1LL<<c[i])-y, y+1)*2;
}
break;
}
cout << ans << '\n';
}
}
Andrew8128