# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1196489 | ofoz | Intercastellar (JOI22_ho_t1) | C++20 | 0 ms | 0 KiB |
from sys import stdout, setrecursionlimit
from math import ceil, floor, sqrt
def cnt_two(x: int):
res = 0
i = 0
while x % 2 == 0:
res += 1
x //= 2
i += 1
if i >= 100: break
return (res, x)
def solve():
n = int(input())
a = []
for _ in range(n): a.append(int(input()))
q = int(input())
queries = []
for _ in range(q): queries.append(int(input()))
last = -1
i = 0
j = 0
cur = 0
c = 0
while i < n and j < q:
x = queries[j]
if x <= cur:
print(last)
j += 1
continue
cnt, after = cnt_two(a[i])
cur += (1<<cnt)
last = after
i += 1
if x <= cur:
print(last)
j += 1
c += 1
if c >= 100: break
solve()