#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
const int NMAX = 2e5 + 5;
ll n, a[NMAX], q, x, cnt[NMAX], i, b;
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < n; i++){
cnt[i] = 1;
while(a[i] % 2 == 0) a[i] /= 2, cnt[i] <<= 1;
}
cin >> q;
while(q--){
cin >> x; x--;
ll t = x - b;
while(t){
if(cnt[i] <= t) t -= cnt[i++];
else {
cnt[i] -= t;
break;
}
}
cout << a[i] << '\n';
b = x;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
15 ms |
3920 KB |
Output is correct |
4 |
Correct |
21 ms |
2368 KB |
Output is correct |
5 |
Correct |
37 ms |
5508 KB |
Output is correct |
6 |
Correct |
26 ms |
4040 KB |
Output is correct |
7 |
Correct |
37 ms |
5488 KB |
Output is correct |
8 |
Correct |
35 ms |
5580 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
336 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 |
0 ms |
328 KB |
Output is correct |
3 |
Correct |
15 ms |
3920 KB |
Output is correct |
4 |
Correct |
21 ms |
2368 KB |
Output is correct |
5 |
Correct |
37 ms |
5508 KB |
Output is correct |
6 |
Correct |
26 ms |
4040 KB |
Output is correct |
7 |
Correct |
37 ms |
5488 KB |
Output is correct |
8 |
Correct |
35 ms |
5580 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
328 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 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 |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
336 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
22 ms |
2956 KB |
Output is correct |
24 |
Correct |
26 ms |
5196 KB |
Output is correct |
25 |
Correct |
50 ms |
8776 KB |
Output is correct |
26 |
Correct |
34 ms |
5504 KB |
Output is correct |
27 |
Correct |
31 ms |
5468 KB |
Output is correct |
28 |
Correct |
57 ms |
9208 KB |
Output is correct |
29 |
Correct |
55 ms |
8712 KB |
Output is correct |
30 |
Correct |
29 ms |
3692 KB |
Output is correct |
31 |
Correct |
57 ms |
9076 KB |
Output is correct |