Queries with Pairs
CodeChefOpen on judge ↗
You have N pairs of integers (Ai, Bi) defined by two arrays A1, A2, ..., AN and B1, B2, ..., BN. You have to handle Q queries of form (a, b). For each such query, find an index i such that Ai ≥ a and Bi ≥ b and the sum Ai - a + Bi - b is minimised. If multiple such indices exist, output the minimum index. Or, output -1 if no such index exists. Input The first line of the input contains two inte
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.
Sign in to chat with the tutor and save your progress.
Sign in to start