#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define debug(x) cout<<#x<<": "<<x<<"\n"
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
// freopen("input.000","r",stdin);
// freopen("output.000","w",stdout);
// srand((unsigned)time(NULL));
// rand()
int n,q,i,l[200005],f[200005],ans[200005],ptr,sum;
pair<int,int> p[200005];
cin>>n;
for (i=1;i<n+1;i++) cin>>l[i];
cin>>q;
for (i=1;i<q+1;i++)
{
cin>>p[i].fi;
p[i].se=i;
}
sort(p+1,p+q+1);
for (i=1;i<n+1;i++)
{
f[i]=1;
while (l[i]%2==0)
{
l[i]/=2;
f[i]*=2;
}
}
ptr=1;sum=0;
for (i=1;i<n+1;i++)
{
sum+=f[i];
while (ptr<=q and p[ptr].fi<=sum)
{
// cout<<i<<" "<<ptr<<"\n";
ans[p[ptr].se]=l[i];
ptr++;
}
}
for (i=1;i<q+1;i++) cout<<ans[i]<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8148 KB |
Output is correct |
2 |
Correct |
4 ms |
8044 KB |
Output is correct |
3 |
Correct |
21 ms |
8772 KB |
Output is correct |
4 |
Correct |
30 ms |
9420 KB |
Output is correct |
5 |
Correct |
44 ms |
10232 KB |
Output is correct |
6 |
Correct |
30 ms |
9268 KB |
Output is correct |
7 |
Correct |
44 ms |
10244 KB |
Output is correct |
8 |
Correct |
42 ms |
10292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8020 KB |
Output is correct |
2 |
Correct |
4 ms |
8020 KB |
Output is correct |
3 |
Correct |
3 ms |
8036 KB |
Output is correct |
4 |
Correct |
4 ms |
8020 KB |
Output is correct |
5 |
Correct |
4 ms |
8144 KB |
Output is correct |
6 |
Correct |
4 ms |
8144 KB |
Output is correct |
7 |
Correct |
4 ms |
8148 KB |
Output is correct |
8 |
Correct |
5 ms |
8056 KB |
Output is correct |
9 |
Correct |
4 ms |
8148 KB |
Output is correct |
10 |
Correct |
4 ms |
8148 KB |
Output is correct |
11 |
Correct |
4 ms |
8148 KB |
Output is correct |
12 |
Correct |
5 ms |
8120 KB |
Output is correct |
13 |
Correct |
4 ms |
8156 KB |
Output is correct |
14 |
Correct |
4 ms |
8148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
8148 KB |
Output is correct |
2 |
Correct |
4 ms |
8044 KB |
Output is correct |
3 |
Correct |
21 ms |
8772 KB |
Output is correct |
4 |
Correct |
30 ms |
9420 KB |
Output is correct |
5 |
Correct |
44 ms |
10232 KB |
Output is correct |
6 |
Correct |
30 ms |
9268 KB |
Output is correct |
7 |
Correct |
44 ms |
10244 KB |
Output is correct |
8 |
Correct |
42 ms |
10292 KB |
Output is correct |
9 |
Correct |
4 ms |
8020 KB |
Output is correct |
10 |
Correct |
4 ms |
8020 KB |
Output is correct |
11 |
Correct |
3 ms |
8036 KB |
Output is correct |
12 |
Correct |
4 ms |
8020 KB |
Output is correct |
13 |
Correct |
4 ms |
8144 KB |
Output is correct |
14 |
Correct |
4 ms |
8144 KB |
Output is correct |
15 |
Correct |
4 ms |
8148 KB |
Output is correct |
16 |
Correct |
5 ms |
8056 KB |
Output is correct |
17 |
Correct |
4 ms |
8148 KB |
Output is correct |
18 |
Correct |
4 ms |
8148 KB |
Output is correct |
19 |
Correct |
4 ms |
8148 KB |
Output is correct |
20 |
Correct |
5 ms |
8120 KB |
Output is correct |
21 |
Correct |
4 ms |
8156 KB |
Output is correct |
22 |
Correct |
4 ms |
8148 KB |
Output is correct |
23 |
Correct |
28 ms |
10292 KB |
Output is correct |
24 |
Correct |
32 ms |
10828 KB |
Output is correct |
25 |
Correct |
60 ms |
13480 KB |
Output is correct |
26 |
Correct |
43 ms |
11308 KB |
Output is correct |
27 |
Correct |
39 ms |
11060 KB |
Output is correct |
28 |
Correct |
71 ms |
13872 KB |
Output is correct |
29 |
Correct |
71 ms |
13356 KB |
Output is correct |
30 |
Correct |
41 ms |
11048 KB |
Output is correct |
31 |
Correct |
72 ms |
13872 KB |
Output is correct |