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 ft first
#define sd second
#define pb push_back
#define nl "\n"
#define int ll
typedef long long ll;
typedef long double ld;
using namespace std;
const int mod = 1e9 + 7;
const int N = 2000;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int T = 1;
while(T--) {
int n;
cin >> n;
int a[n + 1];
vector<vector<int>> v;
for (int i = 1; i <= n; i++) {
cin >> a[i];
int cnt = 1;
while(a[i] % 2 == 0) {
cnt *= 2;
a[i] /= 2;
}
v.push_back({cnt, a[i]});
}
int pre[n + 3];
pre[0] = 0;
//cout << pre[0] << ' ';
for (int i = 1; i < n; i++) {
pre[i] = pre[i - 1] + v[i - 1][0];
// cout << pre[i] << ' ';
}
//cout << nl;
int q;
cin >> q;
while(q--) {
int x;
cin >> x;
int l = 0, r = n + 1;
while(l + 1 < r) {
int m = (l + r) / 2;
if (x > pre[m]) {
l = m;
} else {
r = m;
}
}
cout << v[l][1] << nl;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |