#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<long long, long long>
#define fr first
#define se second
int32_t main() {
int n;
cin >> n;
vector<int> v(n);
vector<pii> g(n);
for (int i = 0; i < n; i++) {
cin >> v[i];
int qtd = 1;
while (!(v[i] & 1LL)) {
v[i] >>= 1;
qtd <<= 1;
}
g[i] = {v[i], qtd};
}
int q;
cin >> q;
vector<pii> queries(q);
for (int i = 0; i < q; i++) {
int x;
cin >> x;
queries[i] = {x, i};
}
sort(queries.begin(), queries.end(), greater<pii>());
vector<int> ans(q);
int qtd = 0;
for (int i = 0; i < n; i++) {
qtd += g[i].se;
while (!queries.empty() && (qtd >= queries.back().fr)) {
ans[queries.back().se] = g[i].fr;
queries.pop_back();
}
}
for (auto u : ans) cout << u << "\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 |
28 ms |
6484 KB |
Output is correct |
4 |
Correct |
44 ms |
6232 KB |
Output is correct |
5 |
Correct |
69 ms |
11856 KB |
Output is correct |
6 |
Correct |
43 ms |
7500 KB |
Output is correct |
7 |
Correct |
80 ms |
11712 KB |
Output is correct |
8 |
Correct |
70 ms |
11856 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 |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
356 KB |
Output is correct |
13 |
Correct |
1 ms |
356 KB |
Output is correct |
14 |
Correct |
1 ms |
356 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 |
28 ms |
6484 KB |
Output is correct |
4 |
Correct |
44 ms |
6232 KB |
Output is correct |
5 |
Correct |
69 ms |
11856 KB |
Output is correct |
6 |
Correct |
43 ms |
7500 KB |
Output is correct |
7 |
Correct |
80 ms |
11712 KB |
Output is correct |
8 |
Correct |
70 ms |
11856 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 |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
356 KB |
Output is correct |
21 |
Correct |
1 ms |
356 KB |
Output is correct |
22 |
Correct |
1 ms |
356 KB |
Output is correct |
23 |
Correct |
40 ms |
6148 KB |
Output is correct |
24 |
Correct |
57 ms |
8256 KB |
Output is correct |
25 |
Correct |
105 ms |
15196 KB |
Output is correct |
26 |
Correct |
74 ms |
9056 KB |
Output is correct |
27 |
Correct |
82 ms |
8780 KB |
Output is correct |
28 |
Correct |
137 ms |
15440 KB |
Output is correct |
29 |
Correct |
142 ms |
14928 KB |
Output is correct |
30 |
Correct |
66 ms |
7504 KB |
Output is correct |
31 |
Correct |
137 ms |
15444 KB |
Output is correct |