#include <bits/stdc++.h>
#define debug(x) (cout<<'['<<(#x)<<':'<<(x)<<']'<<'\n')
using namespace std;
using ll=long long;
int main(){
ios::sync_with_stdio(0), cin.tie(0);
int n;
cin>>n;
vector<array<ll,2>> a(n);
vector<ll> pf(n);
ll s,p;
for(int i=0; i<n; i++){
cin>>s;
p=1;
while((s&1LL)==0){
s>>=1;
p<<=1;
}
a[i][0]=p, a[i][1]=s;
pf[i]=(i ? pf[i-1]+a[i][0] : a[i][0]);
}
int q;
cin>>q;
while(q--){
ll xi;
cin>>xi;
int l=0, r=n-1;
while(r>l+1){
int mid=(l+r)/2;
if(pf[mid]>=xi) r=mid;
else l=mid;
}
if(pf[l]>=xi) r=l;
cout<<a[r][1]<<'\n';
}
return 0;
}
# |
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 |
17 ms |
5512 KB |
Output is correct |
4 |
Correct |
25 ms |
2644 KB |
Output is correct |
5 |
Correct |
43 ms |
7056 KB |
Output is correct |
6 |
Correct |
24 ms |
5396 KB |
Output is correct |
7 |
Correct |
43 ms |
7100 KB |
Output is correct |
8 |
Correct |
44 ms |
7228 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
352 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
320 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 |
332 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 |
17 ms |
5512 KB |
Output is correct |
4 |
Correct |
25 ms |
2644 KB |
Output is correct |
5 |
Correct |
43 ms |
7056 KB |
Output is correct |
6 |
Correct |
24 ms |
5396 KB |
Output is correct |
7 |
Correct |
43 ms |
7100 KB |
Output is correct |
8 |
Correct |
44 ms |
7228 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
316 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
1 ms |
352 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
320 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 |
332 KB |
Output is correct |
23 |
Correct |
23 ms |
3188 KB |
Output is correct |
24 |
Correct |
28 ms |
6284 KB |
Output is correct |
25 |
Correct |
67 ms |
10380 KB |
Output is correct |
26 |
Correct |
36 ms |
6508 KB |
Output is correct |
27 |
Correct |
32 ms |
6604 KB |
Output is correct |
28 |
Correct |
62 ms |
10812 KB |
Output is correct |
29 |
Correct |
61 ms |
10240 KB |
Output is correct |
30 |
Correct |
35 ms |
3916 KB |
Output is correct |
31 |
Correct |
62 ms |
10652 KB |
Output is correct |