#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);ios::sync_with_stdio(0);
//1.
int n, q;
//2.
cin >> n;
long long int v[n], l[n];
vector <long long int> op(n + 1);
op[0] = 0;
//3.
for(int i = 0; i < n; i++){
cin >> v[i];
op[i + 1] = 1;
int v1 = v[i];
while(v[i] % 2 == 0 && v[i] > 0){
v[i] /= 2;
op[i + 1] *= 2;
}
l[i] = v[i];
v[i] = v1;
}
for(int i = 1; i <= n; i++) op[i] += op[i - 1];
vector <long long int> pt(64);
pt[0] = 1;
for(int i = 1; i < 64; i++) pt[i] = pt[i - 1] * 2;
cin >> q;
for(int ii = 0; ii < q; ii++){
long long int x; cin >> x;
auto it = --upper_bound(op.begin(), op.end(), x);
int p = it - op.begin();
if(op[p] < x) p++;
p--;
//cout << x << " este un subordonat al nr " << v[p] << endl;
//cout << " -- > cu nr " << l[p] << endl;
cout << l[p] << endl;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
55 ms |
5028 KB |
Output is correct |
4 |
Correct |
181 ms |
1868 KB |
Output is correct |
5 |
Correct |
254 ms |
5432 KB |
Output is correct |
6 |
Correct |
121 ms |
4436 KB |
Output is correct |
7 |
Correct |
248 ms |
5484 KB |
Output is correct |
8 |
Correct |
248 ms |
5452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
356 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
55 ms |
5028 KB |
Output is correct |
4 |
Correct |
181 ms |
1868 KB |
Output is correct |
5 |
Correct |
254 ms |
5432 KB |
Output is correct |
6 |
Correct |
121 ms |
4436 KB |
Output is correct |
7 |
Correct |
248 ms |
5484 KB |
Output is correct |
8 |
Correct |
248 ms |
5452 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
356 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
460 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
163 ms |
2896 KB |
Output is correct |
24 |
Correct |
120 ms |
5744 KB |
Output is correct |
25 |
Correct |
268 ms |
9184 KB |
Output is correct |
26 |
Correct |
148 ms |
5528 KB |
Output is correct |
27 |
Correct |
121 ms |
5656 KB |
Output is correct |
28 |
Correct |
275 ms |
9196 KB |
Output is correct |
29 |
Correct |
266 ms |
8316 KB |
Output is correct |
30 |
Correct |
190 ms |
3152 KB |
Output is correct |
31 |
Correct |
265 ms |
8520 KB |
Output is correct |