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>
using namespace std;
#define int long long
#define pb push_back
#define pii pair<int,int>
#define all(X) X.begin(),X.end()
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#ifdef local
void setio(){freopen("/Users/iantsai/Library/Mobile Documents/com~apple~CloudDocs/cpp/Empty.md","r",stdin);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
void setio(){}
#define debug(x...)
#endif
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
setio();
int n;
cin>>n;
vector<int>v;
vector<int>cnt(n);
vector<int>ans(n);
for(int i=0;i<n;i++){
int x;
cin>>x;
v.pb(x);
int tmp=0;
//cout<<x<<' ';
while((x>>tmp&1)==0)tmp++;
cnt[i]=(1ll<<tmp);
ans[i]=x/cnt[i];
//cout<<cnt[i]<<' ';
}
int q;
cin>>q;
int p=0,cur=0;
for(int i=0;i<q;i++){
int x;
cin>>x;
while(x>cnt[p]+cur){
cur+=cnt[p];
p++;
}
cout<<ans[p]<<'\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |