#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int N; cin >> N;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
function<int(int)> rec = [&](int x) {
if (x & 1) {
return 1;
}
return 2 * rec(x / 2);
};
vector<array<int, 2>> B;
for (int i = 0; i < N; ++i) {
int x = A[i];
while (x % 2 == 0) {
x /= 2;
}
B.push_back({x, rec(A[i])});
}
for (int i = 1; i < N; ++i) {
B[i][1] += B[i - 1][1];
}
int Q; cin >> Q;
while (Q--) {
long long X; cin >> X;
int L = 0, R = N - 1, res = -1;
while (L <= R) {
int md = (L + R) / 2;
if (B[md][1] >= X) {
res = md;
R = md - 1;
} else {
L = md + 1;
}
}
cout << B[res][0] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
15 ms |
3288 KB |
Output is correct |
4 |
Correct |
18 ms |
1244 KB |
Output is correct |
5 |
Correct |
35 ms |
3288 KB |
Output is correct |
6 |
Correct |
22 ms |
3284 KB |
Output is correct |
7 |
Correct |
35 ms |
3288 KB |
Output is correct |
8 |
Correct |
37 ms |
3288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
468 KB |
Output is correct |
9 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
15 ms |
3288 KB |
Output is correct |
4 |
Correct |
18 ms |
1244 KB |
Output is correct |
5 |
Correct |
35 ms |
3288 KB |
Output is correct |
6 |
Correct |
22 ms |
3284 KB |
Output is correct |
7 |
Correct |
35 ms |
3288 KB |
Output is correct |
8 |
Correct |
37 ms |
3288 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
468 KB |
Output is correct |
17 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |