#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
int a[n+1];
for(int i=1;i<=n;i++){
cin >> a[i];
}
deque<pair<int,int>> d;
for(int i=n;i>=1;i--){
if(a[i]%2!=0){
d.push_front({1,a[i]});
}
else{
int steps=0;
while(a[i]%2==0){
a[i]=a[i]/2;
steps++;
}
steps=(1ll<<steps);
d.push_front({steps,a[i]});
}
}
//cout << '\n';
vector<int> v;
for(int i=0;i<n;i++){
if(i==0){
v.push_back(d[i].first);
}
else{
v.push_back(v[i-1]+d[i].first);
}
}
int q;
cin >> q;
while(q--){
int x;
cin >> x;
int ind=lower_bound(v.begin(),v.end(),x)-v.begin();
cout << d[ind].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 |
22 ms |
7712 KB |
Output is correct |
4 |
Correct |
29 ms |
3272 KB |
Output is correct |
5 |
Correct |
55 ms |
8860 KB |
Output is correct |
6 |
Correct |
31 ms |
6984 KB |
Output is correct |
7 |
Correct |
60 ms |
8980 KB |
Output is correct |
8 |
Correct |
54 ms |
9028 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 |
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 |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
328 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
324 KB |
Output is correct |
14 |
Correct |
1 ms |
340 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 |
22 ms |
7712 KB |
Output is correct |
4 |
Correct |
29 ms |
3272 KB |
Output is correct |
5 |
Correct |
55 ms |
8860 KB |
Output is correct |
6 |
Correct |
31 ms |
6984 KB |
Output is correct |
7 |
Correct |
60 ms |
8980 KB |
Output is correct |
8 |
Correct |
54 ms |
9028 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 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 |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
328 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
328 KB |
Output is correct |
21 |
Correct |
1 ms |
324 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
27 ms |
3612 KB |
Output is correct |
24 |
Correct |
37 ms |
7648 KB |
Output is correct |
25 |
Correct |
71 ms |
12160 KB |
Output is correct |
26 |
Correct |
54 ms |
7788 KB |
Output is correct |
27 |
Correct |
44 ms |
7996 KB |
Output is correct |
28 |
Correct |
79 ms |
12576 KB |
Output is correct |
29 |
Correct |
83 ms |
12036 KB |
Output is correct |
30 |
Correct |
39 ms |
4296 KB |
Output is correct |
31 |
Correct |
82 ms |
12472 KB |
Output is correct |