#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int n, q;
cin >> n;
vector<pair<ll,ll>> pedacos;
for(int i=0; i<n; i++){
int tam;
cin >> tam;
int cnt=1;
while(!(tam&(1))){
tam>>=1;
cnt<<=1;
}
pedacos.push_back({cnt, tam});
}
cin >> q;
ll ptr=-1, qtd=0;
while(q--){
ll pos;
cin >> pos;
while(pos>qtd){
ptr++;
qtd+=pedacos[ptr].first;
}
cout << pedacos[ptr].second << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
6064 KB |
Output is correct |
4 |
Correct |
20 ms |
2520 KB |
Output is correct |
5 |
Correct |
36 ms |
6992 KB |
Output is correct |
6 |
Correct |
21 ms |
5328 KB |
Output is correct |
7 |
Correct |
35 ms |
7124 KB |
Output is correct |
8 |
Correct |
34 ms |
6352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
460 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
600 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
464 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
6064 KB |
Output is correct |
4 |
Correct |
20 ms |
2520 KB |
Output is correct |
5 |
Correct |
36 ms |
6992 KB |
Output is correct |
6 |
Correct |
21 ms |
5328 KB |
Output is correct |
7 |
Correct |
35 ms |
7124 KB |
Output is correct |
8 |
Correct |
34 ms |
6352 KB |
Output is correct |
9 |
Correct |
0 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 |
344 KB |
Output is correct |
15 |
Correct |
0 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
600 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
464 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
19 ms |
3292 KB |
Output is correct |
24 |
Correct |
27 ms |
7380 KB |
Output is correct |
25 |
Correct |
49 ms |
9660 KB |
Output is correct |
26 |
Correct |
33 ms |
5836 KB |
Output is correct |
27 |
Correct |
30 ms |
7380 KB |
Output is correct |
28 |
Correct |
58 ms |
9876 KB |
Output is correct |
29 |
Correct |
51 ms |
8896 KB |
Output is correct |
30 |
Correct |
27 ms |
3792 KB |
Output is correct |
31 |
Correct |
54 ms |
9404 KB |
Output is correct |