#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
int n;
vector<pii> v;
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>n;
for (int i=0; i<n; ++i) {
ll a; cin>>a;
ll cnt=1;
while (a%2==0) a/=2, cnt*=2;
v.push_back(pii(cnt,a));
}
for (int i=1; i<n; ++i) v[i].first+=v[i-1].first;
int q; cin>>q;
while (q--) {
ll x; cin>>x;
cout<<(*upper_bound(v.begin(),v.end(),pii(x,-INT_MAX))).second<<"\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
4556 KB |
Output is correct |
4 |
Correct |
29 ms |
1492 KB |
Output is correct |
5 |
Correct |
44 ms |
4512 KB |
Output is correct |
6 |
Correct |
26 ms |
4556 KB |
Output is correct |
7 |
Correct |
44 ms |
4556 KB |
Output is correct |
8 |
Correct |
42 ms |
4556 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 |
0 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 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
18 ms |
4556 KB |
Output is correct |
4 |
Correct |
29 ms |
1492 KB |
Output is correct |
5 |
Correct |
44 ms |
4512 KB |
Output is correct |
6 |
Correct |
26 ms |
4556 KB |
Output is correct |
7 |
Correct |
44 ms |
4556 KB |
Output is correct |
8 |
Correct |
42 ms |
4556 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
0 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
22 ms |
2132 KB |
Output is correct |
24 |
Correct |
29 ms |
4496 KB |
Output is correct |
25 |
Correct |
54 ms |
5516 KB |
Output is correct |
26 |
Correct |
36 ms |
3020 KB |
Output is correct |
27 |
Correct |
34 ms |
4548 KB |
Output is correct |
28 |
Correct |
62 ms |
4692 KB |
Output is correct |
29 |
Correct |
59 ms |
4528 KB |
Output is correct |
30 |
Correct |
31 ms |
1492 KB |
Output is correct |
31 |
Correct |
63 ms |
4556 KB |
Output is correct |