結果
問題 | No.2844 Birthday Party Decoration |
ユーザー |
![]() |
提出日時 | 2024-08-23 21:23:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 1,178 bytes |
コンパイル時間 | 1,918 ms |
コンパイル使用メモリ | 194,556 KB |
最終ジャッジ日時 | 2025-02-23 23:29:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 4 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ALL(v) v.begin(),v.end() #define dbg(x) cerr << #x << ": " << (x) << endl; template<class F, class S> ostream& operator<<(ostream& os, pair<F,S>& p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template<class Iter> void print(Iter beg, Iter end) { for (Iter itr = beg; itr != end; ++itr) { cerr << *itr << ' '; } cerr << '\n'; } inline bool naraba(bool a, bool b) { return (!a || b); } ll solve() { int N; ll X; cin >> N >> X; vector<int> C(N); for (int i = 0; i < N; ++i) cin >> C[i]; ll ans = 0; for (int i = 0; i < N; ++i) { if (X >> C[i] & 1) continue; ll W = 1LL << C[i]+1; ll L = X / W * W - 1; ll R = L + 1 + (1LL << C[i]); // dbg(W) // dbg(L) // dbg(R) if (L < 0) { // dbg(R-X) ans = max(ans, R-X); } else { // dbg(min(X-L, R-X)) ans = max(ans, min(X-L, R-X)); } } return ans << 1; } int main() { int T; cin >> T; while (T--) { cout << solve() << '\n'; } }