#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<ll> a(n + 5);
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
int q;
cin >> q;
vector<pair<ll, int>> que(q + 5);
vector<ll> ans(q + 5);
for (int i = 1; i <= q; i++) {
cin >> que[i].first;
que[i].second = i;
}
sort(que.begin() + 1, que.begin() + q + 1);
// for (int i = 1; i <= q; i++) {
// cout << que[i].first << " " << que[i].second << "$$" << endl;
// }
int pnt1 = 1;
ll cnt = 0;
for (int i = 1; i <= n; i++) {
ll cnt2 = 1;
while (a[i] % 2 == 0) {
a[i] /= 2;
cnt2 *= 2;
// cout << "@" << a[i] << endl;
}
// cout << cnt << " " << cnt2 << " " << que[pnt1].first << endl;
while (pnt1 <= q && que[pnt1].first >= cnt + 1 && que[pnt1].first <= cnt + cnt2) {
ans[que[pnt1].second] = a[i];
++pnt1;
// cout << "##" << pnt1 << endl;
}
cnt += cnt2;
}
for (int i = 1; i <= q; i++) {
cout << ans[i] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
16 ms |
2720 KB |
Output is correct |
4 |
Correct |
26 ms |
4536 KB |
Output is correct |
5 |
Correct |
46 ms |
6976 KB |
Output is correct |
6 |
Correct |
26 ms |
4004 KB |
Output is correct |
7 |
Correct |
43 ms |
6860 KB |
Output is correct |
8 |
Correct |
52 ms |
6960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
16 ms |
2720 KB |
Output is correct |
4 |
Correct |
26 ms |
4536 KB |
Output is correct |
5 |
Correct |
46 ms |
6976 KB |
Output is correct |
6 |
Correct |
26 ms |
4004 KB |
Output is correct |
7 |
Correct |
43 ms |
6860 KB |
Output is correct |
8 |
Correct |
52 ms |
6960 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
31 ms |
5544 KB |
Output is correct |
24 |
Correct |
32 ms |
6024 KB |
Output is correct |
25 |
Correct |
59 ms |
11916 KB |
Output is correct |
26 |
Correct |
42 ms |
7116 KB |
Output is correct |
27 |
Correct |
39 ms |
6428 KB |
Output is correct |
28 |
Correct |
76 ms |
12248 KB |
Output is correct |
29 |
Correct |
80 ms |
11884 KB |
Output is correct |
30 |
Correct |
38 ms |
7104 KB |
Output is correct |
31 |
Correct |
70 ms |
12228 KB |
Output is correct |