# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1115879 | TrieTr | Intercastellar (JOI22_ho_t1) | C++14 | 64 ms | 13384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
void local() {
#define taskname ""
if (fopen(taskname".inp", "r")) {
freopen(taskname".inp", "r", stdin);
freopen(taskname".out", "w", stdout);
}
}
#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;}
template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;}
const int N = 1e6 + 5;
int n, a[N];
ll pf[N]; int lg[N];
int main() {
fastio; local();
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) {
int x = a[i];
while(x % 2 == 0) lg[i]++, x /= 2;
pf[i] = pf[i - 1] + (1ll << lg[i]);
}
int q; cin >> q;
while(q--) {
ll p; cin >> p;
int lo = 1, hi = n, pos = 0;
while(lo <= hi) {
int mid = (lo + hi) >> 1;
if(pf[mid] < p) lo = (pos = mid) + 1;
else hi = mid - 1;
}
pos++;
cout << a[pos] / (1ll << lg[pos]) << '\n';
}
}
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... |