Submission #1307587

#TimeUsernameProblemLanguageResultExecution timeMemory
1307587samarthkulkarniIntercastellar (JOI22_ho_t1)C++20
100 / 100
53 ms6892 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define vi vector<long long>
#define all(x) x.begin(), x.end()
#define endl "\n"

void solution();
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}



void solution() {
	int n; cin >> n;

	vi a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ll x = a[i];

		int z = 1;
		while (x&1^1) {z += z; x /= 2;}
		b[i] = z;
		if (i > 0)
			b[i] += b[i-1];
	}

	vi temp(n);

	for (int i = 0; i < n; i++) {
		while (a[i]&1^1) a[i]/=2;
		temp[i] = a[i];
	}





	ll q; cin >> q;
	ll j = 0;
	while (q--) {
		ll x; cin >> x;
		while (j < n && b[j] < x) j++;
		cout << temp[j] << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...