Submission #726134

#TimeUsernameProblemLanguageResultExecution timeMemory
726134khanhdz06Intercastellar (JOI22_ho_t1)C++17
25 / 100
54 ms4836 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
int a[200002];
int val[200002];
int cnt[200002];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(nullptr);
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        int tmp = a[i];
        while(tmp%2==0){
            tmp /= 2;
        }
        val[i] = tmp;
        cnt[i] = a[i]/tmp + cnt[i-1];
    }
    cin >> q;
    while(q--){
        int x;
        cin >> x;
        int h = lower_bound(cnt+1, cnt+n+1, x) - cnt;
        cout << val[h]<< '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...