#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);ios::sync_with_stdio(0);
//1.
int n, q;
//2.
cin >> n;
int v[n], l[n];
vector <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 <int> pt(32);
pt[0] = 1;
for(int i = 1; i < 32; i++) pt[i] = pt[i - 1] * 2;
cin >> q;
for(int ii = 0; ii < q; ii++){
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 |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
56 ms |
3360 KB |
Output is correct |
4 |
Correct |
200 ms |
2040 KB |
Output is correct |
5 |
Correct |
254 ms |
4236 KB |
Output is correct |
6 |
Correct |
124 ms |
3156 KB |
Output is correct |
7 |
Correct |
255 ms |
4452 KB |
Output is correct |
8 |
Correct |
267 ms |
4320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
600 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
56 ms |
3360 KB |
Output is correct |
4 |
Correct |
200 ms |
2040 KB |
Output is correct |
5 |
Correct |
254 ms |
4236 KB |
Output is correct |
6 |
Correct |
124 ms |
3156 KB |
Output is correct |
7 |
Correct |
255 ms |
4452 KB |
Output is correct |
8 |
Correct |
267 ms |
4320 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |