이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
typedef long long llong;
const int MAXN = 200000 + 10;
int a[MAXN], n, q;
llong prefix[MAXN];
void solve()
{
for (int i = 1 ; i <= n ; ++i)
{
prefix[i] = prefix[i-1] + (a[i] & -a[i]);
}
int ptr = 1;
llong x;
for (int i = 1 ; i <= q ; ++i)
{
std::cin >> x;
while (prefix[ptr] <= x-1) ++ptr;
std::cout << a[ptr] / (a[ptr] & -(a[ptr])) << '\n';
}
}
void read()
{
std::cin >> n;
for (int i = 1 ; i <= n ; ++i)
{
std::cin >> a[i];
}
std::cin >> q;
}
void fastIO()
{
std::ios_base :: sync_with_stdio(0);
std::cout.tie(nullptr);
std::cin.tie(nullptr);
}
int main()
{
fastIO();
read();
solve();
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... |