# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
575101 | dariasc | Intercastellar (JOI22_ho_t1) | C++14 | 331 ms | 9216 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;
#pragma region header
typedef long long ll;
template <typename Value>
using vec = vector<Value>;
istream &in = cin;
ostream &out = cout;
#define all(x) x.begin(), x.end()
#define fast() cin.tie(0); ios_base::sync_with_stdio(0)
#pragma endregion
void solve()
{
int n; in >> n;
vec<int> a(n);
for (int i = 0; i < n; i++) {
in >> a[i];
}
vec<int> sz(n);
for (int i = 0; i < n; i++) {
int c = 1;
int x = a[i];
while (x % 2 == 0) {
x /= 2;
c *= 2;
}
sz[i] = c;
}
vec<long long> pfx(n, 0);
pfx[0] = sz[0];
for (int i = 1; i < n; i++) {
pfx[i] = sz[i] + pfx[i-1];
}
int q; in >> q;
while (q--) {
long long x; in >> x;
int i = lower_bound(all(pfx), x) - pfx.begin();
int o = a[i];
while (o % 2 == 0) {
o /= 2;
}
out << o << endl;
}
}
int main()
{
fast();
solve(); return 0;
int t; in >> t;
while (t--) {
solve();
}
}
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... |