問題一覧 > 通常問題

No.1077 Noel-chan and the Stars 4

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 230
作問者 : tko919 / テスター : しの
お気に入りにしたユーザー ProblemId : 4318 / 自分の提出
問題文最終更新日: 2020-05-09 14:11:26
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 252 (順位表) の他の問題:

Problem Statement

You are given $N$ points. The height of point $i$ is $Y_i$. Noel-chan can freely move the heights of the points.
One day, Noel-chan decided she wanted to move the points so that their heights become monotonically non-decreasing.
Find the minimum possible total distance that Noel-chan needs to move the points.
However, Noel-chan can only change the height of any point by an integer distance.

Input

$N$
$Y_1\ Y_2\ \cdots\ Y_{N-1}\ Y_N$

The first line contains the number of points $N(1 \le N \le 10^3)$.
The second line contains $N$ integers $Y_i(0 \le Y_i \le 10^4)$.

Output

Output the minimum total distance as an integer.

Sample

Sample 1
Input
6
1 2 0 8 6 9
Output
4

For example, changing $Y_3$ to 2 and $Y_4$ to 6 makes the heights ascending.

Sample 2
Input
10
3 14 15 92 65 35 89 79 32 38
Output
155

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。