#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#define ull unsigned ll
using namespace std;
ll get(ll x, ll k){
if(x & 1) return x;
ll y = x / 2;
ll cnt = y & -y;
if(cnt < k)return get(x / 2, k - cnt);
return get(x / 2, k);
}
ll lsb(ll x){
return x & -x;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
ll a[n + 1];
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int q; cin >> q;
ll cnt = 0;
int ind = 1;
for(int i = 1; i <= q; i++){
ll x; cin >> x;
while(cnt + lsb(a[ind]) < x)ind++, cnt += lsb(a[ind - 1]);
cout << get(a[ind], x - cnt) << "\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 |
17 ms |
2388 KB |
Output is correct |
4 |
Correct |
26 ms |
1988 KB |
Output is correct |
5 |
Correct |
43 ms |
3916 KB |
Output is correct |
6 |
Correct |
26 ms |
2716 KB |
Output is correct |
7 |
Correct |
48 ms |
3896 KB |
Output is correct |
8 |
Correct |
45 ms |
3964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 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 |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 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 |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
212 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 |
17 ms |
2388 KB |
Output is correct |
4 |
Correct |
26 ms |
1988 KB |
Output is correct |
5 |
Correct |
43 ms |
3916 KB |
Output is correct |
6 |
Correct |
26 ms |
2716 KB |
Output is correct |
7 |
Correct |
48 ms |
3896 KB |
Output is correct |
8 |
Correct |
45 ms |
3964 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 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 |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 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 |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
25 ms |
2716 KB |
Output is correct |
24 |
Correct |
41 ms |
4116 KB |
Output is correct |
25 |
Correct |
71 ms |
7248 KB |
Output is correct |
26 |
Correct |
41 ms |
4564 KB |
Output is correct |
27 |
Correct |
41 ms |
4384 KB |
Output is correct |
28 |
Correct |
76 ms |
7692 KB |
Output is correct |
29 |
Correct |
67 ms |
7128 KB |
Output is correct |
30 |
Correct |
42 ms |
3532 KB |
Output is correct |
31 |
Correct |
83 ms |
7516 KB |
Output is correct |