제출 #1287228

#제출 시각아이디문제언어결과실행 시간메모리
1287228tunademayoIntercastellar (JOI22_ho_t1)C++20
100 / 100
57 ms5336 KiB
#include<bits/stdc++.h>
using namespace std;

#define ll long long 

const bool Multitest = 0;

const int N = 2e5 + 10;

ll a[N], cnt[N];
int n, q;

void work()
{
	cin >> n;
	
	for(int i = 1 ; i <= n ; i++) cin >> a[i];
	
	for(int i = 1 ; i <= n ; i++)
	{
		cnt[i] = 1;
		while(a[i] % 2 == 0)
		{
			cnt[i] *= 2;
			a[i] /= 2;
		}
		cnt[i] += cnt[i - 1];
	}
	cin >> q;
	
	while(q--)
	{
		ll x;	cin >> x;
		
		int l = 1, r = n, pos = 0;
		
		while(l <= r)
		{
			int mid = (l + r) >> 1;
			
			if(cnt[mid] < x) l = mid + 1, pos = mid;
			else r = mid - 1;
		}
		
		cout << a[pos + 1] << '\n';
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);	cout.tie(0);
	
	int q = 1;
	
	if(Multitest)	cin >> q;
	
	while(q--) work();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...