#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<int> a(n+1);
vector<int> l(n+1), r(n+1);
r[0] = 0;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
l[i] = r[i-1]+1;
int cnt=1;
while(a[i]%2==0) {
cnt*=2;
a[i]/=2;
}
r[i] = l[i]+cnt-1;
}
int p = 1;
int q; cin >> q;
for (int i = 0; i < q; ++i) {
int x; cin >> x;
while (!(l[p]<= x && x <= r[p])) {
p++;
}
cout << a[p] << "\n";
}
return 0;
}
# |
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 |
21 ms |
5524 KB |
Output is correct |
4 |
Correct |
27 ms |
2724 KB |
Output is correct |
5 |
Correct |
43 ms |
7116 KB |
Output is correct |
6 |
Correct |
30 ms |
5324 KB |
Output is correct |
7 |
Correct |
45 ms |
7040 KB |
Output is correct |
8 |
Correct |
42 ms |
7120 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 |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
320 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 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 |
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 |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
21 ms |
5524 KB |
Output is correct |
4 |
Correct |
27 ms |
2724 KB |
Output is correct |
5 |
Correct |
43 ms |
7116 KB |
Output is correct |
6 |
Correct |
30 ms |
5324 KB |
Output is correct |
7 |
Correct |
45 ms |
7040 KB |
Output is correct |
8 |
Correct |
42 ms |
7120 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
320 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
1 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 |
27 ms |
3308 KB |
Output is correct |
24 |
Correct |
30 ms |
6356 KB |
Output is correct |
25 |
Correct |
62 ms |
10388 KB |
Output is correct |
26 |
Correct |
41 ms |
6480 KB |
Output is correct |
27 |
Correct |
38 ms |
6604 KB |
Output is correct |
28 |
Correct |
77 ms |
10728 KB |
Output is correct |
29 |
Correct |
68 ms |
10256 KB |
Output is correct |
30 |
Correct |
36 ms |
3904 KB |
Output is correct |
31 |
Correct |
72 ms |
10672 KB |
Output is correct |