Submission #939580

#TimeUsernameProblemLanguageResultExecution timeMemory
939580TAhmed33Intercastellar (JOI22_ho_t1)C++98
100 / 100
65 ms9340 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 25;
pair <ll, ll> a[MAXN];
int n, q;
void solve () {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll x; cin >> x;
		ll c = 0;
		while (!(x & 1)) {
			c++; x /= 2;
		}
		a[i] = {(1ll << c) + a[i - 1].first, x};
	}
	cin >> q;
	while (q--) {
		ll x; cin >> x;
		int l = 1, r = n, ans = -1;
		while (l <= r) {
			int mid = (l + r) / 2;
			if (a[mid].first >= x) {
				r = mid - 1; ans = mid;
			} else {
				l = mid + 1;
			}
		}
		cout << a[ans].second << '\n';
	}
}	
int main () {
	ios::sync_with_stdio(0); cin.tie(0);
	int t = 1; //cin >> t;
	while (t--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...