|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||512 MB||10||1||1||20.000%|
A heated game of “chess-tidying” starts with a messy board containing several king pieces strewn across the cells. The player’s job is to put all of the pieces into a line along the primary diagonal of the board, which runs along black squares.
In each move, unlike in normal chess, one king may be moved one place either horizontally or vertically (but not both) to another unoccupied cell.
Given an instance of the game, find how many moves you will need in order to finish it.
Figure K.1: Illustration of Sample Input 2. In this case, the minimum number of moves necessary to put all of the kings along the black diagonal is 28 as pictured.
Each of the kings starts at a unique position.
Output the minimum number of moves necessary to cover the main diagonal (r = c) with kings.
3 1 1 2 3 3 2
8 6 4 6 8 5 5 5 4 4 8 5 7 7 4 3 7