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>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define double long double
#define INF 1e18
#define DEBUG 0
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
vector<pair<int,int>>vect(n);
for(int i=0;i<n;i++){
int a,sz=1;
cin>>a;
while(a%2==0){
a/=2;
sz*=2;
}
vect[i]={a,sz};
}
vector<int>tmp;
tmp.push_back(0);
for(int i=0;i<n;i++){
tmp.push_back(vect[i].second+tmp.back());
}
int q;
cin>>q;
while(q--){
int t;
cin>>t;
auto it = (lower_bound(tmp.begin(),tmp.end(),t) - tmp.begin());
cout<<vect[--it].first<<'\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... |