#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, q, temp;
vector<int> a, prefix;
signed main() {
cin >> n;
a = vector<int>(n), prefix = vector<int>(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
temp = __builtin_ctz(a[i]);
a[i] /= (1 << temp);
prefix[i] = (1 << temp);
if(i > 0) prefix[i] += prefix[i - 1];
}
cin >> q;
while(q--) {
cin >> temp;
int l = 0, r = n, mid, ans = 0;
while(l<=r) {
mid = (l + r) / 2;
if(prefix[mid] < temp) {
ans = mid + 1;
l = mid + 1;
} else r = mid - 1;
}
cout << a[ans] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
76 ms |
3476 KB |
Output is correct |
4 |
Correct |
221 ms |
1380 KB |
Output is correct |
5 |
Correct |
306 ms |
3956 KB |
Output is correct |
6 |
Correct |
151 ms |
3140 KB |
Output is correct |
7 |
Correct |
316 ms |
3828 KB |
Output is correct |
8 |
Correct |
330 ms |
3924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
76 ms |
3476 KB |
Output is correct |
4 |
Correct |
221 ms |
1380 KB |
Output is correct |
5 |
Correct |
306 ms |
3956 KB |
Output is correct |
6 |
Correct |
151 ms |
3140 KB |
Output is correct |
7 |
Correct |
316 ms |
3828 KB |
Output is correct |
8 |
Correct |
330 ms |
3924 KB |
Output is correct |
9 |
Correct |
0 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
344 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
187 ms |
2160 KB |
Output is correct |
24 |
Correct |
156 ms |
3412 KB |
Output is correct |
25 |
Correct |
342 ms |
5492 KB |
Output is correct |
26 |
Correct |
230 ms |
3152 KB |
Output is correct |
27 |
Correct |
191 ms |
3136 KB |
Output is correct |
28 |
Correct |
379 ms |
4720 KB |
Output is correct |
29 |
Correct |
372 ms |
3912 KB |
Output is correct |
30 |
Correct |
266 ms |
1508 KB |
Output is correct |
31 |
Correct |
369 ms |
4320 KB |
Output is correct |