You are viewing a single comment's thread. Return to all comments →
Python DP ?, O(N*Q)
def solve(arr, queries): def solve2(batches, d): a = [x for ba in batches for x in accumulate(reversed(ba), max)] b = [x for ba in batches for x in accumulate(ba, max)] return min(max(a[i-2*((i+1)%d)], b[i]) for i in range(d-1, n)) return [solve2(list(batched(arr, d)), d) for d in queries]
Seems like cookies are disabled on this browser, please enable them to open this website
Queries with Fixed Length
You are viewing a single comment's thread. Return to all comments →
Python DP ?, O(N*Q)