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 <iostream>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define ff first
#define ss second
#define MP make_pair
const int mxl = 30;
const int mxn = 2e5 + 10;
int a[mxn], n, q;
pii p[mxn];
void build() {
for(int i = 1; i <= n; i++) {
const int &A = a[i];
for(int k = 0; k < mxl; k++)
if(A & (1LL << k)) {
p[i].ff = (1LL << k);
p[i].ss = (A >> k);
break;
}
p[i].ff += p[i - 1].ff;
}
}
int solve(int x) {
auto it = lower_bound(p + 1, p + n + 1, MP(x, 0LL));
return (*it).ss;
}
signed main() {
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
build();
cin >> q;
while(q--) {
int x;
cin >> x;
cout << solve(x) << '\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... |