#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int>v(n);
for (auto &i : v) cin >> i;
vector<pii>p(n);
for (int i = 0 ; i < n ; i++) {
int num = 1;
while (v[i] % 2 == 0) {
v[i] /= 2;
num *= 2;
}
if (i == 0) p[i] = {num, v[i]};
else p[i] = {num + p[i-1].first, v[i]};
//cout << p[i].first << " " << p[i].second << "\n";
}
int q, x, l = 0;
cin >> q;
while (q--) {
cin >> x;
while (x > p[l].first) l++;
cout << p[l].second << "\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
15 ms |
5512 KB |
Output is correct |
4 |
Correct |
24 ms |
2676 KB |
Output is correct |
5 |
Correct |
35 ms |
7248 KB |
Output is correct |
6 |
Correct |
21 ms |
5468 KB |
Output is correct |
7 |
Correct |
34 ms |
7156 KB |
Output is correct |
8 |
Correct |
37 ms |
7508 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 |
1 ms |
512 KB |
Output is correct |
4 |
Correct |
1 ms |
500 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 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 |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 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 |
15 ms |
5512 KB |
Output is correct |
4 |
Correct |
24 ms |
2676 KB |
Output is correct |
5 |
Correct |
35 ms |
7248 KB |
Output is correct |
6 |
Correct |
21 ms |
5468 KB |
Output is correct |
7 |
Correct |
34 ms |
7156 KB |
Output is correct |
8 |
Correct |
37 ms |
7508 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
500 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
1 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 |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
19 ms |
3416 KB |
Output is correct |
24 |
Correct |
40 ms |
6432 KB |
Output is correct |
25 |
Correct |
47 ms |
10320 KB |
Output is correct |
26 |
Correct |
33 ms |
6736 KB |
Output is correct |
27 |
Correct |
29 ms |
6736 KB |
Output is correct |
28 |
Correct |
55 ms |
10704 KB |
Output is correct |
29 |
Correct |
54 ms |
10284 KB |
Output is correct |
30 |
Correct |
28 ms |
4040 KB |
Output is correct |
31 |
Correct |
56 ms |
10832 KB |
Output is correct |