結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
tama04
|
| 提出日時 | 2024-09-22 23:15:42 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 2,000 ms |
| コード長 | 834 bytes |
| コンパイル時間 | 4,851 ms |
| コンパイル使用メモリ | 281,508 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 23:15:51 |
| 合計ジャッジ時間 | 4,110 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(V) (V).begin(),(V).end()
typedef long long ll;
int main(void) {
int t;
cin >> t;
vector<ll> ans;
while (t > 0) {
ll n, x;
cin >> n >> x;
vector<ll> c(n);
rep(i, n) {
cin >> c[i];
}
sort(all(c), greater<ll>());
ll res = 0;
rep(i, n) {
if (!(x & (1LL << c[i]))) {
ll big = (floor(x / powl(2, c[i])) + 1) * powl(2, c[i]);
ll small = floor(x / powl(2, c[i])) * powl(2, c[i]) - 1;
ll check = floor(x / powl(2, c[i]));
if (check == 0 || abs(x - big) <= abs(x - small)) {
res = 2 * abs(x - big);
break;
}
else {
res = 2 * abs(x - small);
break;
}
}
}
ans.push_back(res);
t--;
}
rep(i, ans.size()) {
cout << ans[i] << endl;
}
return 0;
}
tama04