← All problemsSign in

Building Towers

Majin has built certain brick towers. The N (1 He wishes to modify the towers in the following fashion: He has a list of numbers B_1 through B_N (1 His strength is obviously, limited. It takes Majin a total X (1 Majin would like to know the minimum possible total effort of modifying his towers if he picks the best permutation of heights. The answer is guaranteed to fit within a 32-bit signed integ

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