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 fi first
#define se second
#define eb emplace_back
#define ep emplace
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
const ll INF=1e18;
const ll mod=1e9+7;
int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL);
    int n, q; cin >> n;
    vector<pl> v;
    for(int i=0;i<n;i++)
    {
        int a; cin >> a;
        ll cnt=1;
        while(a%2==0) a/=2, cnt*=2;
        v.eb(cnt, a);
    }
    ll i=0, sum=0;
    cin >> q;
    while(q--)
    {
        ll x; cin >> x;
        while(i<n and sum+v[i].fi<x) sum+=v[i].fi, i++;
        cout << v[i].se << '\n';
    }
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |