#include <bits/stdc++.h>
using namespace std;
int main()
{
long long n;
cin>>n;
long long niza[n];
for(long long i=0; i<n; i++)cin>>niza[i];
long long idx=0;
vector<pair<long long,long long> > v;
for(long long i=n-1; i>=0; i--)
{
if(niza[i]%2)
{
v.push_back({1,niza[i]});
idx++;
}
else
{
long long sob=1;
while(true)
{
niza[i]/=2;
sob*=2;
if(niza[i]%2)break;
}
v.push_back({sob,niza[i]});
idx+=sob;
}
}
reverse(v.begin(),v.end());
long long q;
cin>>q;
idx=0;
long long sum=0;
for(long long i=0; i<q; i++)
{
long long x;
cin>>x;
while(true)
{
if(sum+v[idx].first<x)
{
sum+=v[idx].first;
idx++;
}
else
{
cout<<v[idx].second<<endl;
break;
}
}
}
return 0;
}
# |
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 |
64 ms |
8748 KB |
Output is correct |
4 |
Correct |
172 ms |
2756 KB |
Output is correct |
5 |
Correct |
241 ms |
7348 KB |
Output is correct |
6 |
Correct |
126 ms |
8136 KB |
Output is correct |
7 |
Correct |
263 ms |
7316 KB |
Output is correct |
8 |
Correct |
287 ms |
7884 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 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 |
2 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 |
344 KB |
Output is correct |
12 |
Correct |
2 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 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 |
64 ms |
8748 KB |
Output is correct |
4 |
Correct |
172 ms |
2756 KB |
Output is correct |
5 |
Correct |
241 ms |
7348 KB |
Output is correct |
6 |
Correct |
126 ms |
8136 KB |
Output is correct |
7 |
Correct |
263 ms |
7316 KB |
Output is correct |
8 |
Correct |
287 ms |
7884 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 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 |
2 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 |
344 KB |
Output is correct |
20 |
Correct |
2 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
159 ms |
3532 KB |
Output is correct |
24 |
Correct |
138 ms |
8128 KB |
Output is correct |
25 |
Correct |
312 ms |
11264 KB |
Output is correct |
26 |
Correct |
171 ms |
6588 KB |
Output is correct |
27 |
Correct |
162 ms |
7512 KB |
Output is correct |
28 |
Correct |
334 ms |
11032 KB |
Output is correct |
29 |
Correct |
323 ms |
10420 KB |
Output is correct |
30 |
Correct |
232 ms |
4044 KB |
Output is correct |
31 |
Correct |
314 ms |
10932 KB |
Output is correct |