제출 #643404

#제출 시각아이디문제언어결과실행 시간메모리
643404alanlIntercastellar (JOI22_ho_t1)C++14
100 / 100
96 ms10796 KiB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second
#define rep(X, a,b) for(int X=a;X<b;++X)
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) (int)(a).size()
#define NL "\n"
using namespace std;
typedef pair<long long,long long> pll;
typedef pair<int,int> pii;
typedef long long ll;
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << "," << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const vector<A> &p){
    for(const auto &a:p)
        os << a << " ";
    os << "\n";
    return os;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll> ar(n), cnt(n), base(n);
    rep(i,0,n) cin>>ar[i];
    rep(i,0,n){
    	ll tmp=ar[i], num=0;
    	while(!(tmp&1)){
    		num++;
    		tmp/=2;
    	}
    	cnt[i]=(1ll<<num);
    	base[i]=tmp;
    }
    rep(i,1,n) cnt[i]+=cnt[i-1];
    int q;
    cin>>q;
    while(q--){
    	ll x;
    	cin>>x;
    	int l=-1, r=n-1;
    	while(l<r-1){
    		int mid=(l+r)>>1;
    		if(cnt[mid]>=x) r=mid;
    		else l=mid;
    	}
    	cout<<base[r]<<NL;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...