이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define ll long long
#define ln '\n'
const int N = 2e5 + 5;
ll n, a[N];
vector<ll> pfx, val;
void solve(){
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
pfx.push_back(0);
val.push_back(-1);
for (int i = 0; i < n; i++){
int cnt = 0;
ll x = a[i];
while (x % 2 == 0) {cnt++; x /= 2;}
pfx.push_back((1LL << cnt));
val.push_back(x);
// cout << cnt << ' ' << x << ln;
}
for (int i = 1; i < (int)pfx.size(); i++) pfx[i] += pfx[i-1];
int q; cin >> q;
while (q--){
ll x; cin >> x;
int j = lower_bound(pfx.begin(), pfx.end(), x) - pfx.begin();
cout << val[j] << ln;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int TT; cin >> TT;
// while (TT--) {solve();}
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... |