# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1264252 | wedonttalkanymore | Intercastellar (JOI22_ho_t1) | C++20 | 46 ms | 7120 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define pii pair<ll, ll>
#define fi first
#define se second
const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 16;
int n, a[N];
int q;
int pfs[N], val[N];
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
if (fopen(".inp", "r")) {
freopen(".inp", "r", stdin);
freopen(".out", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i <= n; i++) {
int t = a[i], res = 0;
while(t > 0 && t % 2 == 0) {
res++;
t /= 2;
}
pfs[i] = pfs[i - 1] + (1 << res);
val[i] = a[i] / (1 << res);
}
cin >> q;
while(q-- > 0) {
int x;
cin >> x;
auto it = lower_bound(pfs + 1, pfs + n + 1, x) - pfs;
cout << val[it] << '\n';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |