This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define inf INT_MAX
#define longlonginf LONG_LONG_MAX
#define mod 998244353
#define MAXN 200005
#define ll long long
#define deb(x) cerr<<"[ "<<#x<<" = "<<x<<" ]";
#define yes() cout<<"YES\n";
#define no() cout<<"NO\n";
using namespace std;
ll n,m,k,q,x;
ll h;
ll ans = 0;
string subtask;
void solve(){
cin>>n;
vector<ll> v;
vector<ll> va;
ll a[n+5];
for(int i = 1 ; i <= n ; i++){
cin>>a[i];
}
v.push_back(0);
va.push_back(0);
for(int i = 1 ; i <= n ; i++){
k = 1;
while( a[i] % 2 == 0 ){
k *= 2;
a[i] /= 2;
}
x = v.back();
v.push_back(x+k);
va.push_back(a[i]);
}
cin>>q;
while(q--){
cin>>x;
ll dist = distance(v.begin(),lower_bound(v.begin(),v.end(),x));
cout<<va[dist]<<"\n";
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T = 1;
//cin>>T;
for(int i = 0 ; i < T ; i++){
//cout<<"Case #"<<i+1<<": ";
solve();
}
return 0;
}
/*
not i but x
logical operator
wrong example/proof
thoroughly
wrong variables
thinking it wrong
bruh just try some test case
capitals ;-;
wrong data structure lol
count memory usement
corner case
oversized array
orders
statements
size initializer
while con
map -> array
wrong digits??
swapped variables??
check if theres any variabled
that got declared twice
find some pattern
name collision
constraints??!
mod !!
resets
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |