D. 再整理一次水杯

    Type: Default 1000ms 256MiB

再整理一次水杯

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

Csvoner 有 nn 个水杯,每个水杯的容量都是 1010010^{100}

现在给出每个水杯中已有的水量,第 ii 个水杯中的水量为 aia_i。Csvoner 可以给某些水杯倒掉一些水(也可以不倒),使得所有水杯的水量一致。

请问 Csvoner 一共最少需要倒掉多少水?

输入格式

第一行一个整数 nn

接下来一行 nn 个整数,a1ana_1\sim a_n

输出格式

一行一个整数,表示 Csvoner 一共最少需要倒掉的水量

4
3 1 1 4
5

样例解释

给四个水杯分别倒掉 2 0 0 32\ 0\ 0\ 3 单位的水即可。

数据规模与约定

对于 100%100\% 的数据,1n,ai10001\le n,a_i \le 1000

  • 子任务 1(30 分):对于 in1i\le n-1,保证 aiai+1a_i\ge a_{i+1}
  • 子任务 2(30 分):对于 in1i\le n-1,保证 aiai+1a_i\le a_{i+1}
  • 子任务 3(40 分):没有特殊限制。

有兴趣的同学可以想想不用数组能不能做。

2025年新学期选拔赛

Not Attended
Status
Done
Rule
IOI
Problem
4
Start at
2025-2-21 17:00
End at
2025-2-21 19:00
Duration
2 hour(s)
Host
Partic.
80