#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, q; cin >> n;
vector<ll> v(n);
for(ll &x: v) cin >> x;
vector<ll> sth;
for(int i = n-1; i >= 0; i--){
ll c = 1;
while(v[i]%2 != 1) v[i]/=2, c*=2;
sth.pb(c);
}
reverse(sth.begin(), sth.end());
for(int i = 1; i < n; i++) sth[i]+=sth[i-1];
cin >> q;
while(q--){
ll x; cin >> x;
cout << v[lower_bound(sth.begin(), sth.end(), x)-sth.begin()] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
4004 KB |
Output is correct |
4 |
Correct |
29 ms |
1444 KB |
Output is correct |
5 |
Correct |
53 ms |
4040 KB |
Output is correct |
6 |
Correct |
30 ms |
3784 KB |
Output is correct |
7 |
Correct |
50 ms |
4040 KB |
Output is correct |
8 |
Correct |
48 ms |
4068 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
4004 KB |
Output is correct |
4 |
Correct |
29 ms |
1444 KB |
Output is correct |
5 |
Correct |
53 ms |
4040 KB |
Output is correct |
6 |
Correct |
30 ms |
3784 KB |
Output is correct |
7 |
Correct |
50 ms |
4040 KB |
Output is correct |
8 |
Correct |
48 ms |
4068 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
26 ms |
2128 KB |
Output is correct |
24 |
Correct |
32 ms |
3552 KB |
Output is correct |
25 |
Correct |
65 ms |
5440 KB |
Output is correct |
26 |
Correct |
48 ms |
3016 KB |
Output is correct |
27 |
Correct |
45 ms |
3620 KB |
Output is correct |
28 |
Correct |
85 ms |
4668 KB |
Output is correct |
29 |
Correct |
88 ms |
4040 KB |
Output is correct |
30 |
Correct |
42 ms |
1588 KB |
Output is correct |
31 |
Correct |
89 ms |
4404 KB |
Output is correct |