#include <bits/stdc++.h>
#define int int64_t
using namespace std;
vector<int>prefix;
int solve(int k, int l, int r){
if(l == r) return l;
int m = (l+r)/2;
if(prefix[m] - prefix[l-1] < k){
k -= (prefix[m] - prefix[l-1]);
return solve(k, m+1, r);
}
return solve(k, l, m);
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen("input.in", "r", stdin);
//freopen("output.out", "w", stdout);
int n; cin>>n;
vector<int>v(n);
for(auto&u: v) cin>>u;
vector<int>two(n);
prefix.assign(n+1, 0);
for(int i = 0; i<n; ++i){
int a = v[i];
int cur = 1;
while(a % 2 == 0){
a /= 2;
cur *= 2;
}
two[i] = cur;
prefix[i+1] = cur;
}
for(int i = 1; i<=n; ++i){
prefix[i] += prefix[i-1];
}
int q; cin>>q;
for(int i = 0; i<q; ++i){
int a; cin>>a;
int index = solve(a, 1, n);
//cout<<"index "<<index<<endl;
cout<<v[index-1]/two[index-1]<<'\n';
}
cout<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
320 KB |
Output is correct |
3 |
Correct |
18 ms |
5480 KB |
Output is correct |
4 |
Correct |
24 ms |
2648 KB |
Output is correct |
5 |
Correct |
50 ms |
7092 KB |
Output is correct |
6 |
Correct |
25 ms |
5316 KB |
Output is correct |
7 |
Correct |
42 ms |
7132 KB |
Output is correct |
8 |
Correct |
41 ms |
7228 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 |
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 |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
324 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 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 |
320 KB |
Output is correct |
3 |
Correct |
18 ms |
5480 KB |
Output is correct |
4 |
Correct |
24 ms |
2648 KB |
Output is correct |
5 |
Correct |
50 ms |
7092 KB |
Output is correct |
6 |
Correct |
25 ms |
5316 KB |
Output is correct |
7 |
Correct |
42 ms |
7132 KB |
Output is correct |
8 |
Correct |
41 ms |
7228 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 |
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 |
340 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
324 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
22 ms |
3244 KB |
Output is correct |
24 |
Correct |
29 ms |
6280 KB |
Output is correct |
25 |
Correct |
53 ms |
10332 KB |
Output is correct |
26 |
Correct |
45 ms |
6600 KB |
Output is correct |
27 |
Correct |
34 ms |
6684 KB |
Output is correct |
28 |
Correct |
62 ms |
10748 KB |
Output is correct |
29 |
Correct |
64 ms |
10188 KB |
Output is correct |
30 |
Correct |
31 ms |
3904 KB |
Output is correct |
31 |
Correct |
63 ms |
10708 KB |
Output is correct |