Musical Rods
You have $N$ rods with you. The $i$-th rod has a length of $A_i$ and a beauty of $B_i$. You'd like to arrange these rods side-by-side in some order on the number line, starting from $0$. Let $x_i$ be the starting position of the $i$-th rod in an arrangement. The beauty of this arrangement is $$ \sum_{i=1}^N x_i\cdot B_i $$ What is the maximum beauty you can attain? Note that the left endpoin
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