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>
#define endl '\n'
using namespace std;
const int MAXN = 2e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, q;
long long a[MAXN];
long long r[MAXN], cnt[MAXN], pref[MAXN];
void read()
{
cin >> n;
for (int i = 1; i <= n; ++ i)
{
cin >> a[i];
r[i] = a[i];
while(r[i] % (1LL * 2) == 0)
r[i] /= (1LL * 2);
cnt[i] = a[i] / r[i];
pref[i] = pref[i-1] + cnt[i];
}
// for (int i = 1; i <= n; ++ i)
// cout << r[i] << " " << cnt[i] << " " << pref[i] << endl;
}
long long x;
void solve_query()
{
int left = 0, right = n, mid, ans = 0;
while(left <= right)
{
mid = (left + right)/2;
if(pref[mid] < x)
{
ans = mid;
left = mid + 1;
}
else right = mid - 1;
}
ans ++;
cout << r[ans] << endl;
}
void queries()
{
cin >> q;
while(q --)
{
cin >> x;
solve_query();
}
}
int main()
{
speed();
read();
queries();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |