結果
| 問題 |
No.2844 Birthday Party Decoration
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-23 21:07:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 438 bytes |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 65,712 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-08-23 21:07:06 |
| 合計ジャッジ時間 | 1,205 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 |
ソースコード
#include<iostream>
#include<cassert>
using namespace std;
int N,c[60];
long X;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;cin>>T;
for(;T--;)
{
cin>>N>>X;
for(int i=0;i<N;i++)cin>>c[i];
int i=N-1;
while(i>=0&&(X>>c[i]&1))i--;
if(i<0)
{
cout<<"0\n";
continue;
}
const long t=1L<<c[i];
long ans=(X/t*t+t-X)*2;
if(X>>c[i])
{
ans=min(ans,(X-(X/t*t-1))*2);
}
cout<<ans<<"\n";
}
}