← All problemsSign in

Maximise Sum

CodeChefRating 3026Open on judge ↗

You have an array $A = [A_1, A_2, \ldots, A_N]$ of size $N$. Perform **exactly** $K$ operations of the type: Pick index $i$ ($1 \le i \le N$) and, - If $A_i$ is even, replace $A_i$ by $\frac{A_i}{2}$ - If $A_i$ is odd, replace $A_i$ by $A_i+1$ Find the maximum possible sum of the array $A$ after all $K$ operations are complete. Note that you aren't allowed to skip operations. ### Input - The

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