#include <bits/stdc++.h>
using namespace std;
int main() {
//ios_base::sync_with_stdio(0); cin.tie(0);
int n, q;
cin >> n;
int a[n];
for(int i=0; i<n; i++) cin >> a[i];
vector<pair<long long, long long> > v;
v.push_back(make_pair(0, 0));
for(int i=0; i<n; i++) {
long long x = a[i], count = 0;
while(x%2==0) {
x/=2;
count++;
}
long long m = (long long)1<<count;
v.push_back(make_pair(v.back().first+m, x));
}
cin >> q;
while(q--) {
long long x;
cin >> x;
int ans = upper_bound(v.begin(), v.end(), make_pair((long long)x, (long long)0)) - v.begin();
cout << v[ans].second << '\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 |
90 ms |
5284 KB |
Output is correct |
4 |
Correct |
285 ms |
1664 KB |
Output is correct |
5 |
Correct |
369 ms |
5268 KB |
Output is correct |
6 |
Correct |
184 ms |
5160 KB |
Output is correct |
7 |
Correct |
368 ms |
5276 KB |
Output is correct |
8 |
Correct |
367 ms |
5216 KB |
Output is correct |
# |
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 |
0 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 |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
3 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
2 ms |
212 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 |
90 ms |
5284 KB |
Output is correct |
4 |
Correct |
285 ms |
1664 KB |
Output is correct |
5 |
Correct |
369 ms |
5268 KB |
Output is correct |
6 |
Correct |
184 ms |
5160 KB |
Output is correct |
7 |
Correct |
368 ms |
5276 KB |
Output is correct |
8 |
Correct |
367 ms |
5216 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
2 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
2 ms |
212 KB |
Output is correct |
20 |
Correct |
3 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
2 ms |
212 KB |
Output is correct |
23 |
Correct |
274 ms |
2204 KB |
Output is correct |
24 |
Correct |
187 ms |
4976 KB |
Output is correct |
25 |
Correct |
450 ms |
6380 KB |
Output is correct |
26 |
Correct |
257 ms |
3516 KB |
Output is correct |
27 |
Correct |
240 ms |
5040 KB |
Output is correct |
28 |
Correct |
449 ms |
5392 KB |
Output is correct |
29 |
Correct |
468 ms |
5260 KB |
Output is correct |
30 |
Correct |
308 ms |
1604 KB |
Output is correct |
31 |
Correct |
448 ms |
5388 KB |
Output is correct |