結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
ripity
|
| 提出日時 | 2024-08-23 21:44:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 785 bytes |
| コンパイル時間 | 1,704 ms |
| コンパイル使用メモリ | 202,824 KB |
| 最終ジャッジ日時 | 2025-02-23 23:38:28 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void solve() {
int N;
long long X;
cin >> N >> X;
unordered_map<long long, long long> dp, ep;
dp[0] = 0;
for(int i = 0; i < N; i++) {
int c;
cin >> c;
long long x = X & ((1LL << c) - 1);
long long y = X & (1LL << c);
if(y != 0) continue;
for(const auto [l, r] : dp) {
int l2 = min(l, - 1 - x);
int r2 = max(r, (1LL << c) - x);
if(r2 > r) ep[l] = r2;
else ep[l] = r;
if(X < (1LL << c)) continue;
if(l2 < l) ep[l2] = r;
else ep[l] = r;
}
swap(dp, ep);
ep.clear();
}
long long ans = 3LL << 60;
for(const auto &[l, r] : dp) {
ans = min(ans, 2 * (r - l));
}
cout << ans << "\n";
}
int main() {
int T;
cin >> T;
while(T--) solve();
}
ripity