結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
tama04
|
| 提出日時 | 2024-09-22 22:43:15 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 844 bytes |
| コンパイル時間 | 5,894 ms |
| コンパイル使用メモリ | 282,400 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-22 22:43:22 |
| 合計ジャッジ時間 | 4,408 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 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<int> ans;
while (t > 0) {
int n, x;
cin >> n >> x;
vector<int> c(n);
rep(i, n) {
cin >> c[i];
}
sort(all(c), greater<int>());
ll res = 0;
rep(i, n) {
if (!(x & (1 << c[i]))) {
ll big = (floor(x / pow(2, c[i])) + 1) * pow(2, c[i]);
ll small = floor(x / pow(2, c[i])) * pow(2, c[i]) - 1;
ll check = floor(x / pow(2, c[i]));
if (small < 0 || 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