Submission #803270

#TimeUsernameProblemLanguageResultExecution timeMemory
803270hanifchdnIntercastellar (JOI22_ho_t1)C++17
100 / 100
57 ms5368 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fi first
#define se second
 
const int N = 2e5 + 5;
 
ll a[N], pref[N];
 
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, q;
    cin >> n;
    for (int i = 1; i <= n; i++) {
    	cin >> a[i];
    	ll mult = 1;
    	while (a[i] % 2 == 0) a[i] /= 2, mult *= 2;
    	pref[i] = pref[i - 1] + mult;
    }
    cin >> q;
    ll id = 0;
    while (q--) {
    	ll x;
    	cin >> x;
    	while (pref[id] < x) id++;
    	cout << a[id] << "\n";
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...