Choose the capital
CodeChefOpen on judge ↗
In a state, there are $N$ cities arranged in a straight line and enumerated from $1$ to $N$, the $ith$ city having a population of $A_i$. Atsi, being the president of the state, has to decide on which city should be the capital but to do that he wants to know what is the cost of making a particular city a capital. The cost of making any city a capital is the sum of contribution of each person i
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