题目地址:http://codeforces.com/problemset/problem/758/A
A. Holiday Of Equality
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.

Input
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.

Output
In the only line print the integer S — the minimum number of burles which are had to spend.

Examples
inputCopy
5
0 1 2 3 4
outputCopy
10
inputCopy
5
1 1 0 1 1
outputCopy
1
inputCopy
3
1 3 1
outputCopy
4
inputCopy
1
12
outputCopy
0
Note
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<iostream>
using namespace std;
int main()
{int n,ans = 0,x;cin >> n;int maxn = 0;for(int i = 0;i<n;i++){cin >> x;maxn = max(x,maxn);ans += x;}cout << n*maxn - ans <<endl;return 0;}

CF 758A Holiday Of Equality相关推荐

  1. Input dataset is not organized (height = 1) Input dataset is not organized (height = 1)......

    转自:https://www.cnblogs.com/william-chan/p/6404717.html 转自:https://blog.csdn.net/baoxiao7872/article/ ...

  2. 世界语到汉语和英语的自动翻译试验

    世界语到汉语和英语的自动翻译试验             --EChA机器翻译系统概述 0.        本文是我在导师刘涌泉和刘倬先生指导下所做的毕业设计的论文总结. 共分十大部分: 1.     ...

  3. CF小组训练赛 Holiday 19

    A. Balls of Buma 具体题目地址可以直接搜索题目标题 题目大意 "BBWWBB"代表不同颜色的球,要求往这个不同颜色的球构成的球段的某位置放入一个某种颜色的球,如果放 ...

  4. 一场CF的台前幕后(上)

    (重发下这篇原发于 2014-06-03的网易博客) 等你等了五千年,只为这一刹那的回眸一笑. 前奏 大约4月份的时候,业界毒瘤pyx噔噔噔跑过来说:"酷爱!我YY了一道题!准备当CF的C& ...

  5. CF Round#240题解

    第一次参加CF的比赛,MSK19.30,四个小时的时差真心累,第一次CODE到这么夜-- 一开始做了A,C两题,后来做B题的时候我体力和精神集中度就很低了,导致一直WA在4-- 今天起床后再刷B,终于 ...

  6. 一场CF的台前幕后(上)——转

    前奏 大约4月份的时候,业界毒瘤pyx噔噔噔跑过来说:"酷爱!我YY了一道题!准备当CF的C" 我当时就被吓傻了."Yet another Chinese round?& ...

  7. [bzoj1582][Usaco2009 Hol]Holiday Painting 节日画画_线段树

    Holiday Painting 节日画画 bzoj-1582 Usaco-2009 Hol 题目大意:给定两个n*m的01网格图.q次操作,每次将第二个网格图的子矩阵全部变成0或1,问每一次操作后两 ...

  8. 『参考』.net CF组件编程(4)——为自定义组件添加工具箱图标!

    前言: 在前三篇的文章中,和大家一起创建了一个用于TCP连接检测的小组件,如果你记不得了,可以通过以下链接去回顾一下: 『参考』.net CF组件编程(1)--基础之后 『参考』.net CF组件编程 ...

  9. OC对象 vs CF对象

    2019独角兽企业重金招聘Python工程师标准>>> OC对象 vs CF对象 在ARC场景下,对象所有权没有转换 使用__bridge关键字即可实现CF对象和OC对象之间的自由转 ...

最新文章

  1. html5标记汇总,HTML标记汇总(1)_HTML教程
  2. 前端进阶之如何正确判断this的指向?
  3. c++17(18)-重载I/O运算符
  4. oracle -239报错,解决: ./check_oracle_health --connect orcl --mode connection-time 报错的问题...
  5. 一般处理程序(ashx)和页面处理程序(aspx)的区别
  6. python装饰器带参数函数二阶导数公式_一文搞定Python装饰器,看完面试不再慌
  7. 5 SD配置-企业结构-定义-定义销售组
  8. java技术指标_使用 Micrometer 记录 Java 应用性能指标
  9. Learn ZYNQ (7)
  10. 2个月面了鹅厂的5个部门,心态差点奔溃了......
  11. 关于Initializing Spring root WebApplicationContext解决方法
  12. Android lint工具 检查的常见问题
  13. 计算机硬件只能通过软件使用,日常软件分享 篇四:还在用鲁大师?查看电脑硬件信息可以用这些免费的软件!...
  14. 一篇文章理解Ext4文件系统的目录
  15. 浅谈逻辑漏洞:越权漏洞、密码找回漏洞、支付逻辑漏洞、指定账户恶意攻击、登录体系安全、业务一致性安全、业务数据篡改、验证码突破、数据重放安全
  16. HTML基础(一)HTML标签
  17. Linux之nslookup命令使用详解—网络故障定位(一)
  18. 信息学奥赛一本通:1026:空格分隔输出
  19. 半桥llc 增益 matlab程序,半桥LLC谐振设计多路输出辅助电源
  20. 虚拟盘可以挂载多个服务器吗,两台云服务器挂载一个云硬盘吗

热门文章

  1. React16版本中render阶段放弃了使用递归
  2. uc os ii与linux,uC/OS-II嵌入式实时操作系统的几大特点
  3. 【安装】安装ros机器人系统和无人机环境配置常见问题总结
  4. MySql的数据文件迁移
  5. 医学分割综述 MedISeg(tricks,challenges and future directions)
  6. 已知$g=14_则php表达式$h=$g+=10_运算后的结果是,【北语网院】19春《PHP》作业_2(100分)...
  7. miRDeep2 学习及安装篇
  8. [SDS]Simultaneous Detection and Segmentation
  9. 韩顺平老师讲诉如何学习PHP
  10. CSS图片与文字水平对齐