#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t,f[200009],X[200009],F[200009],g[200009],lef,rig,mid;
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(i=1; i<=a; i++){
cin>>f[i];
}
for(i=a; i>=1; i--){
c=f[i];d=0;
while(c%2==0){
c/=2;d++;
}
F[i]=c;g[i]=f[i]/c;
}
for(i=a; i>=1; i--){
g[i]+=g[i+1];
}
cin>>tes;
for(t=1; t<=tes; t++){
cin>>c;c=g[1]-c+1;
lef=0;rig=a+1;
while(1){
if(lef+1>=rig) break;
mid=(lef+rig)/2;
if(g[mid]<c){
rig=mid;
}else{
lef=mid;
}
}
cout<<F[lef]<<"\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
21 ms |
5388 KB |
Output is correct |
4 |
Correct |
42 ms |
2544 KB |
Output is correct |
5 |
Correct |
64 ms |
6412 KB |
Output is correct |
6 |
Correct |
31 ms |
5324 KB |
Output is correct |
7 |
Correct |
69 ms |
6520 KB |
Output is correct |
8 |
Correct |
62 ms |
6404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
21 ms |
5388 KB |
Output is correct |
4 |
Correct |
42 ms |
2544 KB |
Output is correct |
5 |
Correct |
64 ms |
6412 KB |
Output is correct |
6 |
Correct |
31 ms |
5324 KB |
Output is correct |
7 |
Correct |
69 ms |
6520 KB |
Output is correct |
8 |
Correct |
62 ms |
6404 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
344 KB |
Output is correct |
23 |
Correct |
28 ms |
3020 KB |
Output is correct |
24 |
Correct |
34 ms |
5916 KB |
Output is correct |
25 |
Correct |
74 ms |
9544 KB |
Output is correct |
26 |
Correct |
45 ms |
6216 KB |
Output is correct |
27 |
Correct |
45 ms |
6160 KB |
Output is correct |
28 |
Correct |
86 ms |
10440 KB |
Output is correct |
29 |
Correct |
84 ms |
9552 KB |
Output is correct |
30 |
Correct |
47 ms |
3752 KB |
Output is correct |
31 |
Correct |
87 ms |
10428 KB |
Output is correct |