#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> a(n);
vector<pair<int, int>> b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
int cnt = 1;
while (a[i] % 2 == 0) {
a[i] /= 2;
cnt *= 2;
}
b[i] = {cnt, a[i]};
}
int q;
cin >> q;
ll sum = 0;
int pnt = -1;
while (q--) {
ll x;
cin >> x;
while (pnt < n && sum + b[pnt + 1].first < x) {
sum += b[++pnt].first;
}
cout << b[pnt + 1].second << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
3144 KB |
Output is correct |
4 |
Correct |
25 ms |
1600 KB |
Output is correct |
5 |
Correct |
49 ms |
3548 KB |
Output is correct |
6 |
Correct |
28 ms |
2904 KB |
Output is correct |
7 |
Correct |
44 ms |
3476 KB |
Output is correct |
8 |
Correct |
55 ms |
3540 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
20 ms |
3144 KB |
Output is correct |
4 |
Correct |
25 ms |
1600 KB |
Output is correct |
5 |
Correct |
49 ms |
3548 KB |
Output is correct |
6 |
Correct |
28 ms |
2904 KB |
Output is correct |
7 |
Correct |
44 ms |
3476 KB |
Output is correct |
8 |
Correct |
55 ms |
3540 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 |
0 ms |
316 KB |
Output is correct |
13 |
Correct |
1 ms |
320 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
324 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
34 ms |
2332 KB |
Output is correct |
24 |
Correct |
34 ms |
3264 KB |
Output is correct |
25 |
Correct |
69 ms |
5040 KB |
Output is correct |
26 |
Correct |
39 ms |
2892 KB |
Output is correct |
27 |
Correct |
36 ms |
2976 KB |
Output is correct |
28 |
Correct |
69 ms |
4224 KB |
Output is correct |
29 |
Correct |
71 ms |
3572 KB |
Output is correct |
30 |
Correct |
45 ms |
1772 KB |
Output is correct |
31 |
Correct |
71 ms |
4000 KB |
Output is correct |