#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;
pair<int,int> get_nr(int x) {
int nr = 1;
while(x%2 == 0) {
nr = nr * 2;
x /= 2;
}
return {nr,x};
}
int answer(int x) {
for (int i = 1; i <= n; i++) {
auto val = get_nr(a[i]);
if (val.first < x) {
x -= val.first;
} else {
return val.second;
}
}
return -1;
}
int32_t main() {
in >> n;
for (int i = 1; i <= n; i++) {
in >> a[i];
}
in >> q;
for (int i = 1; i <= q; i++) {
int x;
in >> x;
out << answer(x) << "\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 |
Execution timed out |
2073 ms |
1924 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
2 ms |
212 KB |
Output is correct |
8 |
Correct |
5 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
16 ms |
316 KB |
Output is correct |
12 |
Correct |
22 ms |
212 KB |
Output is correct |
13 |
Correct |
5 ms |
212 KB |
Output is correct |
14 |
Correct |
17 ms |
336 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 |
Execution timed out |
2073 ms |
1924 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |