← All problemsSign in

Coin Arrangement

CSESAdditional Problems IIOpen on judge ↗

There is a 2 \times n grid whose each cell contains some number of coins. The total number of coins is 2n. Your task is to arrange the coins so that each cell contains exactly one coin. On each move you can choose any coin and move it one step left, right, up or down. What is the minimum number of moves if you act optimally? Input The first input line has an integer n: the width of the grid.

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