#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int mxN = 2e5 + 5;
ll n,a[mxN],q,val[mxN];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
val[i] = 1;
while(a[i] % 2 == 0){
val[i] *= 2;
a[i] /= 2;
}
}
cin >> q;
ll l = 0,num = 0;
while(q--){
ll x;
cin >> x;
while(x - num > val[l]) num += val[l++];
cout << a[l] << '\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
4100 KB |
Output is correct |
4 |
Correct |
18 ms |
2396 KB |
Output is correct |
5 |
Correct |
31 ms |
5468 KB |
Output is correct |
6 |
Correct |
21 ms |
4184 KB |
Output is correct |
7 |
Correct |
39 ms |
5632 KB |
Output is correct |
8 |
Correct |
28 ms |
5716 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
460 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 |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
4100 KB |
Output is correct |
4 |
Correct |
18 ms |
2396 KB |
Output is correct |
5 |
Correct |
31 ms |
5468 KB |
Output is correct |
6 |
Correct |
21 ms |
4184 KB |
Output is correct |
7 |
Correct |
39 ms |
5632 KB |
Output is correct |
8 |
Correct |
28 ms |
5716 KB |
Output is correct |
9 |
Correct |
1 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
460 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
16 ms |
3152 KB |
Output is correct |
24 |
Correct |
21 ms |
5212 KB |
Output is correct |
25 |
Correct |
42 ms |
8792 KB |
Output is correct |
26 |
Correct |
28 ms |
5720 KB |
Output is correct |
27 |
Correct |
26 ms |
5716 KB |
Output is correct |
28 |
Correct |
48 ms |
9300 KB |
Output is correct |
29 |
Correct |
46 ms |
8836 KB |
Output is correct |
30 |
Correct |
26 ms |
3676 KB |
Output is correct |
31 |
Correct |
54 ms |
9128 KB |
Output is correct |