이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 2e5 + 25;
pair <ll, ll> a[MAXN];
int n, q;
void solve () {
cin >> n;
for (int i = 1; i <= n; i++) {
ll x; cin >> x;
ll c = 0;
while (!(x & 1)) {
c++; x /= 2;
}
a[i] = {(1ll << c) + a[i - 1].first, x};
}
cin >> q;
while (q--) {
ll x; cin >> x;
int l = 1, r = n, ans = -1;
while (l <= r) {
int mid = (l + r) / 2;
if (a[mid].first >= x) {
r = mid - 1; ans = mid;
} else {
l = mid + 1;
}
}
cout << a[ans].second << '\n';
}
}
int main () {
ios::sync_with_stdio(0); cin.tie(0);
int t = 1; //cin >> t;
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... |