No.693 square1001 and Permutation 2
レベル :
/ AI推定難易度 : 425
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 256 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 344
作問者 :
square1001
/ テスター :
37zigen
タグ : / 解いたユーザー数 344
作問者 :
37zigen
問題文最終更新日: 2026-06-25 09:58:23
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 192
(順位表)
の他の問題:
Problem Statement
square1001 found $N$ integers $A_1, A_2, \cdots, A_N$, each between $1$ and $N$ inclusive.
For every $1$ yen he pays, he can perform the following operation $1$ time. He may perform the operation any number of times.
- Choose $1$ of the $N$ numbers and change its value by $1$.
Input
$N$ $A_1 \ A_2 \ A_3 \ \cdots A_N$
- Line $1$ contains an integer $N$, representing the number of integers.
- Line $2$ contains $N$ integers $A_1, A_2, \cdots, A_N$, separated by spaces.
Constraints
- $1 \leq N \leq 50$
- $1 \leq A_i \leq N \ (1 \leq i \leq N)$
Output
Print the minimum amount (in yen) that square1001 has to pay, on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
4 3 1 4 1
Output
1
For example, if you increase $A_4$ by $1$, the $N$ numbers become $3, 1, 4, 2$, and each of $1$ through $4$ appears $1$ time. In that case, the cost is $1$ yen.
Sample 2
Input
9 1 4 1 4 2 1 3 5 6
Output
18
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。