이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define ll long long
#define pii pair<ll,ll>
#define mp make_pair
#define endl "\n"
#define out(x) cout << #x << " = " << x << endl
#define outp(x) cout << #x << ".first = " << x.first << " " << #x << ".second = " << x.second << endl
#pragma GCC optimize("Ofast")
int n,q;
ll arr[200005];
pii res[200005];
vector<ll> pre;
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
cin>>n;
pre.push_back(0);
for (int i=1;i<=n;i++) {
cin>>arr[i];
ll cnt=1, r=arr[i];
while(1){
if (r%2==1) break;
r/=2; cnt*=2;
}
res[i] = mp(cnt, r);
pre.push_back(pre.back()+cnt);
}
//for (int i=1;i<=n;i++) outp(res[i]), cout<<pre[i]<<endl;
cin>>q;
while(q--){
ll x; cin>>x;
int pos = lower_bound(pre.begin(),pre.end(),x) - pre.begin();
//cout<<"#";
cout<<res[pos].second<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |