#include <bits/stdc++.h>
using namespace std;
long long a[200001];
long long b[200001];
long long c[200001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//freopen(".INP","r",stdin);
// freopen(".OUT","w",stdout);
int n;
cin>>n;
for (int i=1;i<=n;i++){
cin>>a[i];
long long dd=a[i];
while (dd%2==0){
dd/=2;
}
b[i]=a[i]/dd;
b[i]+=b[i-1];
c[i]=dd;
}
int q;
cin>>q;
for (int i=1;i<=q;i++){
long long h;
cin>>h;
int l=1,r=n,ans=n;
while (l<=r){
int mid=(l+r)/2;
if (b[mid]>=h){
r=mid-1;
ans=mid;
}
else l=mid+1;
}
cout<<c[ans]<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
17 ms |
5512 KB |
Output is correct |
4 |
Correct |
27 ms |
2692 KB |
Output is correct |
5 |
Correct |
40 ms |
7116 KB |
Output is correct |
6 |
Correct |
24 ms |
5384 KB |
Output is correct |
7 |
Correct |
45 ms |
7116 KB |
Output is correct |
8 |
Correct |
40 ms |
7132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
332 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
17 ms |
5512 KB |
Output is correct |
4 |
Correct |
27 ms |
2692 KB |
Output is correct |
5 |
Correct |
40 ms |
7116 KB |
Output is correct |
6 |
Correct |
24 ms |
5384 KB |
Output is correct |
7 |
Correct |
45 ms |
7116 KB |
Output is correct |
8 |
Correct |
40 ms |
7132 KB |
Output is correct |
9 |
Correct |
0 ms |
328 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 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 |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
332 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 |
21 ms |
3292 KB |
Output is correct |
24 |
Correct |
27 ms |
6304 KB |
Output is correct |
25 |
Correct |
53 ms |
10376 KB |
Output is correct |
26 |
Correct |
39 ms |
6576 KB |
Output is correct |
27 |
Correct |
33 ms |
6672 KB |
Output is correct |
28 |
Correct |
60 ms |
10708 KB |
Output is correct |
29 |
Correct |
64 ms |
10284 KB |
Output is correct |
30 |
Correct |
30 ms |
3912 KB |
Output is correct |
31 |
Correct |
61 ms |
10668 KB |
Output is correct |