# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
752039 | taniakallos | Intercastellar (JOI22_ho_t1) | C++14 | 474 ms | 9388 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 <iostream>
using namespace std;
const int N = 2e5;
int n, q;
int v[N+1], exp[N+1];
long long pw[N+1];
int cb(int st, int dr, long long val) //>=
{
while (st <= dr)
{
int mid = (st+dr)/2;
if (val <= pw[mid])
dr = mid-1;
else
st = mid+1;
}
return st;
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++)
cin >> v[i];
for (int i = 1; i <= n; i++)
{
int cop = v[i], nr = 0;
while ((cop & 1) == 0)
{
cop = (cop >> 1);
nr++;
}
exp[i] = nr;
}
for (int i = 1; i <= n; i++)
pw[i] = 1 << exp[i];
for (int i = 1; i <= n; i++)
pw[i] += pw[i-1];
cin >> q;
for (int i = 1; i <= q; i++)
{
long long x;
cin >> x;
int p = cb(1, n, x);
cout << (v[p] >> exp[p]) << '\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... |