이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#ifndef DEBUG
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,abm,mmx,fma,popcnt")
#endif
#include <bits/stdc++.h>
#define int long long
using ll = long long;
using namespace std;
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vector<int> a(n);
for (auto &x : a) cin >> x;
vector<int> pref(n+1, 0);
vector<int> len(n);
for (int i=0; i<n; i++) {
int x = a[i];
int cnt = 1;
while (x%2==0) {
cnt<<=1;
x>>=1;
}
pref[i+1] = pref[i] + cnt;
len[i] = x;
}
int q; cin >> q;
vector<int> query(q);
for (auto &x : query) cin >> x;
for (auto &x : query) {
int l = -1, r = n-1;
while (r-l > 1) {
int m = (l+r)/2;
if (x>pref[m+1]) l=m;
else r=m;
}
cout << len[r] << "\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... |