#include <bits/stdc++.h>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0);
#define FOR(i, a, b) for (int i = a; i <= b; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int INF = 1e16;
const int N = 200005;
int a[N], b[N];
int num[N], pre[N];
signed main() {
IO;
int n, x;
cin >> n;
FOR(i, 1, n) {
cin >> x;
int cnt = 1;
while (x % 2 == 0) {
x /= 2;
cnt *= 2;
}
num[i] = x;
pre[i] = pre[i - 1] + cnt;
}
int q;
cin >> q;
while (q--) {
cin >> x;
int id = lower_bound(pre + 1, pre + n + 1, x) - pre;
cout << num[id] << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
14 ms |
5212 KB |
Output is correct |
4 |
Correct |
24 ms |
3792 KB |
Output is correct |
5 |
Correct |
41 ms |
7124 KB |
Output is correct |
6 |
Correct |
22 ms |
5716 KB |
Output is correct |
7 |
Correct |
37 ms |
6736 KB |
Output is correct |
8 |
Correct |
37 ms |
6748 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2516 KB |
Output is correct |
5 |
Correct |
1 ms |
2520 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 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
14 ms |
5212 KB |
Output is correct |
4 |
Correct |
24 ms |
3792 KB |
Output is correct |
5 |
Correct |
41 ms |
7124 KB |
Output is correct |
6 |
Correct |
22 ms |
5716 KB |
Output is correct |
7 |
Correct |
37 ms |
6736 KB |
Output is correct |
8 |
Correct |
37 ms |
6748 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2516 KB |
Output is correct |
13 |
Correct |
1 ms |
2520 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 |
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 |
21 ms |
4888 KB |
Output is correct |
24 |
Correct |
26 ms |
7260 KB |
Output is correct |
25 |
Correct |
52 ms |
10064 KB |
Output is correct |
26 |
Correct |
34 ms |
8016 KB |
Output is correct |
27 |
Correct |
31 ms |
7508 KB |
Output is correct |
28 |
Correct |
59 ms |
10320 KB |
Output is correct |
29 |
Correct |
55 ms |
9852 KB |
Output is correct |
30 |
Correct |
31 ms |
5720 KB |
Output is correct |
31 |
Correct |
62 ms |
10324 KB |
Output is correct |