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;
#define int long long int
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define pb push_back
void solve() {
int n; cin>>n;
int a[n];
vi vals(n),sums(n);
int sum=0;
for (int i=0;i<n;i++) {
cin>>a[i];
int m=(a[i] & (-a[i]));
a[i]=a[i]/(a[i] & (-a[i]));
sum+=m;
vals[i]=a[i]; sums[i]=sum;
}
int q; cin>>q;
while(q--) {
int x; cin>>x;
int lo = 0,hi = n - 1;
while (lo < hi) {
int mid = (lo + hi) / 2;
if (sums[mid] < x) lo = mid + 1;
else hi = mid;
}
cout<<vals[hi]<<endl;
}
return;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int tt=1; //cin>>tt;
while(tt--) {
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... |