Submission #1272239

#TimeUsernameProblemLanguageResultExecution timeMemory
1272239danglayloi1Intercastellar (JOI22_ho_t1)C++20
100 / 100
54 ms5304 KiB
#include <bits/stdc++.h>
#define ii pair<int, int>
#define fi first
#define se second
#define inf 0x3f3f3f3f3f3f3f3f
using namespace std;
using ll = long long;
const ll mod=1e9+7;
const int nx=2e5+5;
int n, q;
ll a[nx], pre[nx];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        cin>>a[i];
        ll cur=1;
        while(a[i]%2==0) a[i]/=2, cur<<=1;
        pre[i]=pre[i-1]+cur;
    }
    cin>>q;
    while(q--)
    {
        ll x;
        cin>>x;
        int d=1, c=n, g, pos=n+1;
        while(d<=c)
        {
            g=(d+c)>>1;
            if(pre[g]>=x) pos=g, c=g-1;
            else d=g+1;
        }
        cout<<a[pos]<<'\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...