#include <bits/stdc++.h>
#define int long long
using namespace std;
#ifdef LOCAL
ifstream in("in.in");
ofstream out("out.out");
#else
#define in cin
#define out cout
#endif
const int nmax = 200005;
int n,a[nmax],q,nr[nmax],val[nmax];
pair<int,int> get_nr(int x) {
int nr = 1;
while(x%2 == 0) {
nr = nr * 2;
x /= 2;
}
return {nr,x};
}
pair<int,int> qs[nmax];
int sol[nmax];
int32_t main() {
in >> n;
for (int i = 1; i <= n; i++) {
in >> a[i];
}
for (int i = 1; i <= n; i++) {
auto v = get_nr(a[i]);
nr[i] = v.first;
val[i] = v.second;
nr[i] += nr[i - 1];
}
in >> q;
for (int i = 1; i <= q; i++) {
int x;
in >> x;
qs[i] = {x, i};
}
sort(qs + 1, qs + 1 + n);
for (int i = 1; i <= q; i++) {
for (int j = 1; j <= n; j++) {
if (nr[j] >= qs[i].first) {
sol[qs[i].second] = val[j];
break;
}
}
}
for (int i = 1; i <= q; i++) {
out << sol[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 |
Incorrect |
46 ms |
7776 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
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 |
Incorrect |
46 ms |
7776 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |