Submission #1264407

#TimeUsernameProblemLanguageResultExecution timeMemory
1264407kustov_vadim_533Intercastellar (JOI22_ho_t1)C++20
100 / 100
40 ms4676 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#define len(v) (int)((v).size())

const int inf = 1e9;

inline void solve(){
	int n;
	cin >> n;

	vector<int> a(n);
	for (int i = 0; i < n; ++i){
		cin >> a[i];
	}

	int q;
	cin >> q;

	vector<ll> x(q);
	for (int i = 0; i < q; ++i){
		cin >> x[i];
	}

	ll sum = 0;
	int j = 0;
	for (int i = 0; i < n; ++i){
		int c = 1;
		while (a[i] % 2 == 0){
			a[i] /= 2;
			c *= 2;
		}

		sum += c;
		while (j < q && x[j] <= sum){
			cout << a[i] << '\n'; 
			++j;
		}
	}
	
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(60);

	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...