← All problemsSign in

Chefland Squads and the Army Chief

CodeChefRating 2788Open on judge ↗

The Chefland Army has $N$ soldiers, standing in a row and numbered $1$ through $N$ from left to right. Their heights from left to right are $A_1, A_2, \ldots, A_N$. A *squad* consists of one or more consecutive soldiers, i.e. soldiers $L$ through $R$ (inclusive) for some $L$ and $R$ such that $1 \le L \le R \le N$. The *strength* of a squad is defined in the following way: for each soldier in t

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