#include <bits/stdc++.h>
using namespace std;
#ifdef ngu
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = (int) 2e5 + 5;
int n, q;
int a[N];
long long cnt[N];
int get(int &x) {
int res = 1;
while (x % 2 == 0) {
x /= 2;
res *= 2;
}
return res;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
#ifdef ngu
freopen("test.inp", "r", stdin);
freopen("test.out", "w", stdout);
#endif
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
cnt[i] = cnt[i - 1] + get(a[i]);
}
cin >> q;
while (q--) {
long long x;
cin >> x;
int p = lower_bound(cnt + 1, cnt + n + 1, x) - cnt;
cout << a[p] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2520 KB |
Output is correct |
3 |
Correct |
15 ms |
3668 KB |
Output is correct |
4 |
Correct |
25 ms |
3932 KB |
Output is correct |
5 |
Correct |
41 ms |
4688 KB |
Output is correct |
6 |
Correct |
24 ms |
3676 KB |
Output is correct |
7 |
Correct |
42 ms |
4868 KB |
Output is correct |
8 |
Correct |
41 ms |
4928 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2480 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2520 KB |
Output is correct |
3 |
Correct |
15 ms |
3668 KB |
Output is correct |
4 |
Correct |
25 ms |
3932 KB |
Output is correct |
5 |
Correct |
41 ms |
4688 KB |
Output is correct |
6 |
Correct |
24 ms |
3676 KB |
Output is correct |
7 |
Correct |
42 ms |
4868 KB |
Output is correct |
8 |
Correct |
41 ms |
4928 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
1 ms |
2392 KB |
Output is correct |
17 |
Correct |
1 ms |
2392 KB |
Output is correct |
18 |
Correct |
1 ms |
2480 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
26 ms |
4700 KB |
Output is correct |
24 |
Correct |
32 ms |
5204 KB |
Output is correct |
25 |
Correct |
68 ms |
7960 KB |
Output is correct |
26 |
Correct |
36 ms |
5716 KB |
Output is correct |
27 |
Correct |
33 ms |
5724 KB |
Output is correct |
28 |
Correct |
61 ms |
8332 KB |
Output is correct |
29 |
Correct |
59 ms |
8020 KB |
Output is correct |
30 |
Correct |
32 ms |
5724 KB |
Output is correct |
31 |
Correct |
62 ms |
8276 KB |
Output is correct |