#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define fi first
#define se second
#define ll long long
#define pb push_back
#define ii pair<int,int>
template <class T>
using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int nax=2e3+5;
#define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
optimise;
int n;
cin>>n;
pair<int,int> tab[n];
for (int i = 0; i < n; ++i)
{
int x;
int cnt=1;
cin>>x;
while(x%2==0){
cnt*=2;
x/=2;
}
tab[i]={cnt,x};
}
int pre[n];
pre[0]=tab[0].fi;
for (int i = 1; i < n; ++i)
{
pre[i]=tab[i].fi+pre[i-1];
}
int q;
cin>>q;
while(q--){
int x;
cin>>x;
int l=-1;
int r=n-1;
while(r-l>1){
int mid=(r+l)/2;
if(pre[mid]>=x) r=mid;
else l=mid;
}
cout << tab[r].se<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
48 ms |
3360 KB |
Output is correct |
4 |
Correct |
172 ms |
2100 KB |
Output is correct |
5 |
Correct |
221 ms |
4872 KB |
Output is correct |
6 |
Correct |
104 ms |
3412 KB |
Output is correct |
7 |
Correct |
226 ms |
4768 KB |
Output is correct |
8 |
Correct |
214 ms |
4976 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 |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
456 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 |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
348 KB |
Output is correct |
9 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
48 ms |
3360 KB |
Output is correct |
4 |
Correct |
172 ms |
2100 KB |
Output is correct |
5 |
Correct |
221 ms |
4872 KB |
Output is correct |
6 |
Correct |
104 ms |
3412 KB |
Output is correct |
7 |
Correct |
226 ms |
4768 KB |
Output is correct |
8 |
Correct |
214 ms |
4976 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
456 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 |
344 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
18 |
Halted |
0 ms |
0 KB |
- |