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 ll = long long;
#define int ll
using namespace std;
#define sz(x) (int)(x).size()
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, l, r) for(int i = l; i >= r; i--)
#define fi first
#define se second
#define mod 998244353
#define db(x) cerr << __LINE__ << " " << #x << " " << x << "\n"
using vi = vector<int>;
using pi = pair<int, int>;
const ll N = 200005;
const ll inf = 1e18;
int n, a[N];
vector<pi> v;
void solve(){
cin >> n;
foru(i, 1, n){
cin >> a[i];
int c = 1;
while(a[i] % 2 == 0){
a[i] >>= 1;
c <<= 1;
}
v.push_back(pi(c, a[i]));
}
int sum = 0, z = 0;
int q; cin >> q;
while(q--){
int x; cin >> x;
while(z < n and sum + v[z].fi < x){
sum += v[z].fi;
z++;
}
cout << v[z].se << "\n";
}
}
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0);
int t = 1;
while(t--){
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |