#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define INF 1e9
using namespace std;
typedef long long ll;
void solve()
{
int n; cin >> n;
vector<ll>a(n + 1),s(n + 1);
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
if (a[i] % 2 == 1) {
s[i] = s[i - 1] + 1;
}
else {
for (int j = 1; j <= 30; j++) {
ll num = (1 << j);
if ((a[i] / num) % 2 == 1) {
a[i] = a[i] / num;
s[i] = s[i - 1] + num;
break;
}
}
}
}
int q; cin >> q;
while (q--) {
ll x; cin >> x;
int lo = 1; int hi = n;
while (lo < hi) {
int mid = (lo + hi) / 2;
if (s[mid] < x)lo = mid + 1;
else hi = mid;
}
cout << a[lo] << "\n";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;// cin>>t;
while (t--) solve();
return 0;
}
# |
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 |
14 ms |
3932 KB |
Output is correct |
4 |
Correct |
20 ms |
2396 KB |
Output is correct |
5 |
Correct |
37 ms |
5492 KB |
Output is correct |
6 |
Correct |
21 ms |
4000 KB |
Output is correct |
7 |
Correct |
35 ms |
5724 KB |
Output is correct |
8 |
Correct |
35 ms |
5616 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 |
452 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 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 |
# |
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 |
14 ms |
3932 KB |
Output is correct |
4 |
Correct |
20 ms |
2396 KB |
Output is correct |
5 |
Correct |
37 ms |
5492 KB |
Output is correct |
6 |
Correct |
21 ms |
4000 KB |
Output is correct |
7 |
Correct |
35 ms |
5724 KB |
Output is correct |
8 |
Correct |
35 ms |
5616 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 |
452 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
18 ms |
3164 KB |
Output is correct |
24 |
Correct |
28 ms |
5352 KB |
Output is correct |
25 |
Correct |
47 ms |
8940 KB |
Output is correct |
26 |
Correct |
33 ms |
5716 KB |
Output is correct |
27 |
Correct |
31 ms |
5716 KB |
Output is correct |
28 |
Correct |
56 ms |
9300 KB |
Output is correct |
29 |
Correct |
59 ms |
8764 KB |
Output is correct |
30 |
Correct |
26 ms |
3676 KB |
Output is correct |
31 |
Correct |
60 ms |
9304 KB |
Output is correct |