/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
const int maxn = 2e5 + 10;
int n, q;
ll a[maxn], pref[maxn];
void solve()
{
cin >> n;
for (int i = 1; i <= n; i ++)
{
cin >> a[i];
ll bit = 0;
while(a[i] % ((ll)1 << bit) == 0)
bit ++;
bit --;
pref[i] = pref[i - 1] + ((ll)1 << bit);
a[i] /= ((ll)1 << bit);
}
cin >> q;
for (int i = 1; i <= q; i ++)
{
int l = 0, r = n;
ll x;
cin >> x;
while(l <= r)
{
int m = (l + r) / 2;
if (pref[m] < x)
l = m + 1;
else
r = m - 1;
}
cout << a[l] << endl;
}
}
int main()
{
speed();
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
3608 KB |
Output is correct |
4 |
Correct |
27 ms |
2352 KB |
Output is correct |
5 |
Correct |
47 ms |
5496 KB |
Output is correct |
6 |
Correct |
28 ms |
4044 KB |
Output is correct |
7 |
Correct |
48 ms |
5536 KB |
Output is correct |
8 |
Correct |
46 ms |
5648 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
19 ms |
3608 KB |
Output is correct |
4 |
Correct |
27 ms |
2352 KB |
Output is correct |
5 |
Correct |
47 ms |
5496 KB |
Output is correct |
6 |
Correct |
28 ms |
4044 KB |
Output is correct |
7 |
Correct |
48 ms |
5536 KB |
Output is correct |
8 |
Correct |
46 ms |
5648 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
26 ms |
3020 KB |
Output is correct |
24 |
Correct |
33 ms |
5168 KB |
Output is correct |
25 |
Correct |
61 ms |
8728 KB |
Output is correct |
26 |
Correct |
53 ms |
5516 KB |
Output is correct |
27 |
Correct |
54 ms |
5552 KB |
Output is correct |
28 |
Correct |
91 ms |
9328 KB |
Output is correct |
29 |
Correct |
106 ms |
8616 KB |
Output is correct |
30 |
Correct |
45 ms |
3652 KB |
Output is correct |
31 |
Correct |
98 ms |
9168 KB |
Output is correct |