This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
main() {
#ifdef Home
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif // Home
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, q, x, y, l, r, m;
cin >> n;
ll pref[n + 1], num[n + 1];
pref[0] = num[0] = 0;
for(int i = 1; i <= n; ++ i) {
cin >> x;
y = __builtin_ctz(x);
pref[i] = pref[i - 1] + (1<<y);
num[i] =(x>>y);
}
for(cin >> q; q --> 0;) {
cin >> x;
l = 0, r = n;
for(; l + 1 < r;) {
m = (l + r) / 2;
(pref[m] < x ? l : r) = m;
}
cout << num[r] << '\n';
}
}
Compilation message (stderr)
Main.cpp:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
12 | main() {
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |