This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vei;
typedef vector<vei> vevei;
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) a.size()
#define con cout << "NO\n"
#define coe cout << "YES\n";
#define str string
#define pb push_back
#define ff first
#define sc second
#define pii pair<int, int>
#define mxe max_element
#define mne min_element
#define stf shrink_to_fit
#define f(i, l, r) for (int i = (l); i < (r); i++)
#define double ld
#define int ll
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n; cin >> n;
vector<int> a(n);
f(i, 0, n) cin >> a[i];
vector<int> cnt(n, 0), val(n);
f(i, 0, n) {
int c = 1, v = a[i];
while (v % 2 == 0) {
c *= 2;
v /= 2;
}
cnt[i] = c; val[i] = v;
}
vector<int> pref(n + 1, 0);
f(i, 1, n + 1) pref[i] = pref[i - 1] + cnt[i - 1];
int q; cin >> q;
while (q--) {
int x; cin >> x;
int L = 0, R = n;
while (R - L > 1) {
int M = (L + R) / 2;
if (pref[M] >= x) R = M;
else L = M;
}
cout << val[L] << '\n';
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |