← All problemsSign in

MAX-SEG

CodeChefRating 3080Open on judge ↗

You are given two arrays $A$ and $B$ of length $N$. The array $B$ contains only zeros and ones. You are given $Q$ queries, each of which consists of two integers $L$ and $R$, $L\leq R$. Consider a partition of the interval $[L, R]$ into some $k \geq 1$ subintervals $[l_1, r_1], [l_2, r_2], \dots, [l_k, r_k]$ satisfying the following conditions: * $l_1 = L$ and $r_k = R$ * $l_i \leq r_i$ for ever

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