Codeforces Round #392 (Div. 2) A.Holiday Of Equality
来源:互联网 发布:淘宝刻章违法吗 编辑:程序博客网 时间:2024/06/07 13:15
In Berland it is the holiday of equality. In honor of the holiday the king decided to equalize the welfare of all citizens in Berland by the expense of the state treasury.
Totally in Berland there are n citizens, the welfare of each of them is estimated as the integer in ai burles (burle is the currency in Berland).
You are the royal treasurer, which needs to count the minimum charges of the kingdom on the king's present. The king can only give money, he hasn't a power to take away them.
The first line contains the integer n (1 ≤ n ≤ 100) — the number of citizens in the kingdom.
The second line contains n integers a1, a2, ..., an, where ai (0 ≤ ai ≤ 106) — the welfare of the i-th citizen.
In the only line print the integer S — the minimum number of burles which are had to spend.
50 1 2 3 4
10
51 1 0 1 1
1
31 3 1
4
112
0
In the first example if we add to the first citizen 4 burles, to the second 3, to the third 2 and to the fourth 1, then the welfare of all citizens will equal 4.
In the second example it is enough to give one burle to the third citizen.
In the third example it is necessary to give two burles to the first and the third citizens to make the welfare of citizens equal 3.
In the fourth example it is possible to give nothing to everyone because all citizens have 12 burles.
嗯~
#include "stdio.h"#include "string.h"#include "algorithm"using namespace std;int main(){ int n,Max,sum; int a[200]; while(scanf("%d",&n)!=EOF){ sum=0; Max=0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); Max=max(Max,a[i]); } for(int i=0;i<n;i++){ sum+=(Max-a[i]); } printf("%d\n",sum); } return 0;}
- CF-Codeforces Round #392 (Div. 2)-A-Holiday Of Equality
- Codeforces Round #392 (Div. 2) A.Holiday Of Equality
- Codeforces Round #392(Div. 2) A Holiday Of Equality【水题】
- Codeforces Round #392 (Div. 2)A Holiday Of Equality
- Codeforces Round #392 (Div. 2) 758A Holiday Of Equality
- Codeforces Round #392 (Div. 2)Holiday Of Equality
- Codeforces Round #392 (Div. 2) A. Holiday Of Equality(水题)
- 【codeforces 758A】Holiday Of Equality
- Codeforces 758A-Holiday Of Equality
- CodeForces 758A Holiday Of Equality
- Holiday Of Equality (Codeforces-758A)
- A. Holiday Of Equality
- CF758 A. Holiday Of Equality (水题)
- Codeforces758A Holiday Of Equality
- Codeforces Round #260 (Div. 2) D. A Lot of Games
- Codeforces Round #302 (Div. 2) A. Set of Strings
- Codeforces Round #302 (Div. 2) A. Set of Strings
- Codeforces Round #363 (Div. 2)[A]Launch of Collider
- 51Nod-1536-不一样的猜数游戏
- 【分享】食灵12卷全+追傩之章 漫画合集
- Python多个装饰器的顺序
- hdu1087最长(最大)上升子序列
- GitHub使用教程
- Codeforces Round #392 (Div. 2) A.Holiday Of Equality
- Codeforces Round #392 (Div. 2) B - Blown Garland
- Scala学习笔记(0) 导言
- QT开发--Visual Studio2013--配置代码32bit、64bit环境
- OpenCV开发中的一些笔记
- Leetcode 394. Decode String
- one way of bitwise operation of C using struct
- Troubleshooting Segmentation Violations/Faults
- 纸上得来终觉浅,构建之法东北师大站2016秋季学期