This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, q;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
cin >> q;
vector<int> v2(n, 1);
for (int i = 0; i < n; i++) {
while (a[i] % 2 == 0) {
a[i] /= 2;
v2[i] *= 2;
}
}
vector<int> pref(n + 1);
for (int i = 0; i < n; i++) pref[i + 1] = pref[i] + v2[i];
while (q--) {
int x;
cin >> x;
x--;
cout << a[upper_bound(pref.begin(), pref.end(), x) - pref.begin() - 1] << "\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |