#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";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
16 ms |
3416 KB |
Output is correct |
4 |
Correct |
36 ms |
3760 KB |
Output is correct |
5 |
Correct |
42 ms |
4688 KB |
Output is correct |
6 |
Correct |
23 ms |
3836 KB |
Output is correct |
7 |
Correct |
42 ms |
4788 KB |
Output is correct |
8 |
Correct |
43 ms |
4944 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 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 |
1 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 |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2552 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
16 ms |
3416 KB |
Output is correct |
4 |
Correct |
36 ms |
3760 KB |
Output is correct |
5 |
Correct |
42 ms |
4688 KB |
Output is correct |
6 |
Correct |
23 ms |
3836 KB |
Output is correct |
7 |
Correct |
42 ms |
4788 KB |
Output is correct |
8 |
Correct |
43 ms |
4944 KB |
Output is correct |
9 |
Correct |
1 ms |
2648 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 |
1 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 |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2552 KB |
Output is correct |
20 |
Correct |
1 ms |
2392 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2392 KB |
Output is correct |
23 |
Correct |
24 ms |
4700 KB |
Output is correct |
24 |
Correct |
30 ms |
5348 KB |
Output is correct |
25 |
Correct |
71 ms |
8128 KB |
Output is correct |
26 |
Correct |
35 ms |
6060 KB |
Output is correct |
27 |
Correct |
35 ms |
5752 KB |
Output is correct |
28 |
Correct |
62 ms |
8544 KB |
Output is correct |
29 |
Correct |
61 ms |
8040 KB |
Output is correct |
30 |
Correct |
33 ms |
5720 KB |
Output is correct |
31 |
Correct |
65 ms |
8500 KB |
Output is correct |