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>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
ll a[n + 1];
for(ll i = 1; i <= n; ++i){
cin >> a[i];
}
map<ll, ll>ans;
ll idx = 1ll;
ll q;
cin >> q;
ll k[q + 1];
for(ll i = 1; i <= q; ++i){
cin >> k[i];
}
ll last = 0ll;
for(ll i = 1; i <= n; ++i){
ll L = last + 1ll;
ll cnt = 1ll;
while(a[i] % 2 == 0){
cnt = cnt * 2ll;
a[i] /= 2;
}
ll R = L + cnt - 1;
while(k[idx] >= L and k[idx] <= R){
ans[k[idx]] = a[i];
idx++;
}
last = R;
}
for(ll i = 1; i <= q; ++i){
cout << ans[k[i]] << '\n';
}
return 0;
// 1000 * 1000 | 33 ?
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |