#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
int n;
cin>>n;
vector<int> v(n),cnt(n),pre(n);
for(int &i:v) cin>>i;
for(int i=0;i<n;i++){
cnt[i]=v[i]&-v[i];
}
for(int i=0;i<n;i++){
pre[i]=cnt[i];
if(i!=0) pre[i]+=pre[i-1];
}
int q;
cin>>q;
while(q--){
int x;
cin>>x;
int l=0,r=n-1,mid;
if(cnt[0]>=x) r=0;
while(r-l>1){
mid=(l+r)>>1;
if(pre[mid]>=x) r=mid;
else l=mid;
}
cout<<(v[r]/cnt[r])<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
88 ms |
5456 KB |
Output is correct |
4 |
Correct |
225 ms |
2808 KB |
Output is correct |
5 |
Correct |
321 ms |
7056 KB |
Output is correct |
6 |
Correct |
171 ms |
5640 KB |
Output is correct |
7 |
Correct |
336 ms |
7204 KB |
Output is correct |
8 |
Correct |
330 ms |
7340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
3 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
88 ms |
5456 KB |
Output is correct |
4 |
Correct |
225 ms |
2808 KB |
Output is correct |
5 |
Correct |
321 ms |
7056 KB |
Output is correct |
6 |
Correct |
171 ms |
5640 KB |
Output is correct |
7 |
Correct |
336 ms |
7204 KB |
Output is correct |
8 |
Correct |
330 ms |
7340 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
3 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
217 ms |
3296 KB |
Output is correct |
24 |
Correct |
178 ms |
6344 KB |
Output is correct |
25 |
Correct |
364 ms |
10424 KB |
Output is correct |
26 |
Correct |
217 ms |
6608 KB |
Output is correct |
27 |
Correct |
198 ms |
6592 KB |
Output is correct |
28 |
Correct |
398 ms |
10896 KB |
Output is correct |
29 |
Correct |
394 ms |
10260 KB |
Output is correct |
30 |
Correct |
267 ms |
3940 KB |
Output is correct |
31 |
Correct |
399 ms |
10836 KB |
Output is correct |