← All problemsSign in

A problem with queries

You are given an array of length n with elements P = {p0, p1, ........, pn-1}. Your task is to calculate the result of the following expression: min0≤i≤n-d ( maxi≤j pj) In other words, if ai = max(pi, pi+1, ......., pi+d-1), then you need to find the value of min(a0, a1, ........, an-d). Given P and q queries (each query consists of an integer, s), print the result of each query on a new line.

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start