#include <bits//stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_multiset;
#define ll long long
#define iloop(m, h) for (auto i = m; i != h; i += (m < h ? 1 : -1))
#define jloop(m, h) for (auto j = m; j != h; j += (m < h ? 1 : -1))
#define kloop(m, h) for (auto k = m; k != h; k += (m < h ? 1 : -1))
#define pll pair<ll, ll>
#define INF 1000000000000000
#define MOD1 1000000007
#define MOD2 998244353
#define MOD3 1000000009
ll n, q;
pll a[200005];
pll qu[200005];
ll ans[200005];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
iloop(0, n) {
cin >> a[i].first;
a[i].second = 1;
while (!(a[i].first&1)) {
a[i].first >>= 1;
a[i].second <<= 1;
}
}
cin >> q;
iloop(0, q) {
cin >> qu[i].first;
qu[i].second = i;
}
sort(qu, qu + q);
ll ccn = 0, ci = 0;
iloop(0, q) {
while (ccn < n && ci + a[ccn].second < qu[i].first) {
ci += a[ccn].second;
ccn++;
}
ans[qu[i].second] = a[ccn].first;
}
iloop(0, q) cout << ans[i] << "\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... |