제출 #593537

#제출 시각아이디문제언어결과실행 시간메모리
593537oleh1421Intercastellar (JOI22_ho_t1)C++17
100 / 100
72 ms5700 KiB
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#define y2 y_2
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
mt19937 rnd(time(NULL));
const ll mod=998244353;
const int N=610;
const int Lg=16;

void solve(){
    int n;cin>>n;
    vector<pair<ll,ll> >v;
    for (int i=1;i<=n;i++){
        ll x;cin>>x;
        ll y=1;
        while (x%2==0){
            y*=2;
            x/=2;
        }
        v.push_back({y,x});
    }
    int q;cin>>q;
    int j=0;
    ll sum=0ll;
    for (int i=1;i<=q;i++){
        ll x;cin>>x;
        while (sum<x){
            sum+=v[j++].first;
        }
        cout<<v[j-1].second<<endl;
    }

}
int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int tt=1;
//    cin>>tt;
    while (tt--){
        solve();
    }
    return 0;

}


/**
3
5 2 7 3 1 6 8 4
**/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...