← All problemsSign in

Multiply 2 to Minimize

CodeChefRating 1785Open on judge ↗

Given an array $A$, we can do the following operation as many times as needed : - Choose $(i, j)$ such that $1 \le i < j \le |A|$ and $A_i = A_j$, then delete both the values from the array, and append $2 \cdot A_i$ at the end of the array. For example, suppose $A = [3, 1, 3, 4, 4]$, and we choose $(i, j) = (1, 3)$, then the new array formed is $[1, 4, 4, 6]$. Let $f(A)$ denote the minimum pos

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