#include <iostream>
using namespace std;
const int N = 2e5;
int n, q;
int v[N+1], exp[N+1];
long long pw[N+1];
int cb(int st, int dr, long long val) //>=
{
while (st <= dr)
{
int mid = (st+dr)/2;
if (val <= pw[mid])
dr = mid-1;
else
st = mid+1;
}
return st;
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> v[i];
for (int i = 1; i <= n; i++)
{
int cop = v[i], nr = 0;
while ((cop & 1) == 0)
{
cop = (cop >> 1);
nr++;
}
exp[i] = nr;
}
for (int i = 1; i <= n; i++)
pw[i] = 1 << exp[i];
for (int i = 1; i <= n; i++)
pw[i] += pw[i-1];
cin >> q;
for (int i = 1; i <= q; i++)
{
long long x;
cin >> x;
int p = cb(1, n, x);
cout << (v[p] >> exp[p]) << '\n';
}
return 0;
}
Compilation message
Main.cpp:8:13: warning: built-in function 'exp' declared as non-function [-Wbuiltin-declaration-mismatch]
8 | int v[N+1], exp[N+1];
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
87 ms |
3916 KB |
Output is correct |
4 |
Correct |
285 ms |
2356 KB |
Output is correct |
5 |
Correct |
353 ms |
5528 KB |
Output is correct |
6 |
Correct |
172 ms |
4188 KB |
Output is correct |
7 |
Correct |
360 ms |
5424 KB |
Output is correct |
8 |
Correct |
350 ms |
5600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
3 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
308 KB |
Output is correct |
11 |
Correct |
3 ms |
340 KB |
Output is correct |
12 |
Correct |
4 ms |
320 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
87 ms |
3916 KB |
Output is correct |
4 |
Correct |
285 ms |
2356 KB |
Output is correct |
5 |
Correct |
353 ms |
5528 KB |
Output is correct |
6 |
Correct |
172 ms |
4188 KB |
Output is correct |
7 |
Correct |
360 ms |
5424 KB |
Output is correct |
8 |
Correct |
350 ms |
5600 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
3 ms |
328 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
308 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
4 ms |
320 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
204 ms |
3032 KB |
Output is correct |
24 |
Correct |
185 ms |
5232 KB |
Output is correct |
25 |
Correct |
399 ms |
8896 KB |
Output is correct |
26 |
Correct |
262 ms |
5456 KB |
Output is correct |
27 |
Correct |
215 ms |
5452 KB |
Output is correct |
28 |
Correct |
432 ms |
9388 KB |
Output is correct |
29 |
Correct |
474 ms |
8688 KB |
Output is correct |
30 |
Correct |
274 ms |
3684 KB |
Output is correct |
31 |
Correct |
452 ms |
9108 KB |
Output is correct |