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 <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define INF 1e9
using namespace std;
typedef long long ll;
void solve()
{
int n; cin >> n;
vector<ll>a(n + 1),s(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
if (a[i] % 2 == 1) {
s[i] = s[i - 1] + 1;
}
else {
for (int j = 1; j <= 20; j++) {
if ((a[i] / (1 << j)) % 2 == 1) {
a[i] = a[i] / (1 << j);
s[i] = s[i - 1] + (1 << j);
break;
}
}
}
}
int q; cin >> q;
while (q--) {
ll x; cin >> x;
int lo = 1; int hi = n;
while (lo < hi) {
int mid = (lo + hi) / 2;
if (s[mid] < x)lo = mid + 1;
else hi = mid;
}
cout << a[lo] << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;// cin>>t;
while (t--) solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |