This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define endl "\n"
#define finp for(int i=0; i<n; i++)
#define fknp for(int k=0; k<n; k++)
#define yeap cout<<"YES"<<endl
#define nope cout<<"NO"<<endl
#define inpintn int n; cin>>n
#define inpintarrn int arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define inpllarrn long long arr[n]; for(int i=0; i<n; i++){cin>>arr[i];}
#define ll long long
ll expo(ll n){
ll count=0;
while(n%2==0){
count++;
n/=2;
}
return count;
}
using namespace std;
int main ()
{
ll n;
cin>>n;
ll arr[n];
for (int i=0; i<n; i++){
cin>>arr[i];
}
ll q;
cin>>q;
ll brr[q];
for (int i=0; i<q; i++){
cin>>brr[i];
}
ll crr[n];
for (int i=0; i<n; i++){
int x=expo(arr[i]);
int y=pow(2,x);
crr[i]=y;
}
for (int i=0; i<q; i++){
ll coun=0;
for (int j=0; j<n; j++){
if (j==n-1){
if (coun>=brr[i]){
ll z=arr[n-2]/crr[n-2];
cout << z << " ";
break;
} else {
ll z=arr[n-1]/crr[n-1];
cout << z << " ";
break;
}
} else if (brr[i]>coun){
coun+=crr[j];
} else {
ll z=arr[j-1]/crr[j-1];
cout << z << " ";
break;
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |