結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 22:46:04 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,114 bytes |
| コンパイル時間 | 1,197 ms |
| コンパイル使用メモリ | 109,528 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-08-23 22:46:06 |
| 合計ジャッジ時間 | 1,763 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P;
const int MAX_N = 60;
int N;
ll X, lb, ans;
int c[MAX_N];
int t;
void solve();
int main() {
cin >> t;
for (int tt = 0; tt < t; tt++)
solve();
return 0;
}
void solve() {
cin >> N >> X;
for (int i = 0; i < N; i++)
cin >> c[i];
vector<P> shops;
for (int i = 0; i < N; i++) {
ll tmp = (1LL << c[i]);
if (X & tmp)
continue;
ll q = X / tmp;
shops.push_back(make_pair((q + 1) * tmp, -c[i]));
}
if (shops.empty()) {
cout << 0 << endl;
return;
}
sort(shops.begin(), shops.end(), greater<P>());
shops.push_back(make_pair(X, 0));
lb = X; ans = shops[0].first * 2;
for (int i = 0; i + 1 < shops.size(); i++) {
ll tmp = (1LL << c[i]);
ll q = X / tmp;
if (q == 0)
break;
ll pos = (q - 1) * tmp + (tmp - 1);
lb = min(lb, pos);
ans = min(ans, (shops[i + 1].first - lb) * 2);
}
cout << ans << endl;
}