acm 一道水题:Increase and Decrease 求思路DescriptionPolycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many eq

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/06 19:31:47
acm 一道水题:Increase and Decrease 求思路DescriptionPolycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many eq

acm 一道水题:Increase and Decrease 求思路DescriptionPolycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many eq
acm 一道水题:Increase and Decrease 求思路
Description
Polycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many equal numbers as possible. For that Polycarpus performs the following operation multiple times:
he chooses two elements of the array ai, aj (i ≠ j); he simultaneously increases number ai by 1 and decreases number aj by 1, that is, executes ai = ai + 1 and aj = aj - 1. 
 
The given operation changes exactly two distinct array elements. Polycarpus can apply the described operation an infinite number of times. 
Now he wants to know what maximum number of equal array elements he can get if he performs an arbitrary number of such operation. Help Polycarpus.
Input
The first line contains integer n (1 ≤ n ≤ 105) — the array size. The second line contains space-separated integers a1, a2, ..., an (|ai| ≤ 104) — the original array.
Output
Print a single integer — the maximum number of equal array elements he can get if he performs an arbitrary number of the given operation.
Sample Input
Input2
2 1
Output1
Input3
1 4 1
Output3

acm 一道水题:Increase and Decrease 求思路DescriptionPolycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many eq
先用HASH记录每个数字的出现个数,然后找出出现最多的那个数字ai,数目为MAX1,算出剩下的数字个数N,若是奇数,则ANS=MAX1+N-1,若是偶数,则判断平均数与那个数字ai的大小,若相等则ANS=MAX1+N,否则ANS=MAX1+N-1

acm 一道水题:Increase and Decrease 求思路DescriptionPolycarpus has an array, consisting of n integers a1, a2, ..., an. Polycarpus likes it when numbers in an array match. That's why he wants the array to have as many eq an increase是什么意思? 凯恩斯理论,关于通货膨胀的一道题The correct economic strategy according to Keynes during an inflationary period is to:a) Increase government spendingb) Decrease taxationc) Increase social security paymentsd) Move to a budget surplus 一道acm的排序题Snow_storm有n(0 一道AP微观经济题Operating in the intermediate range of the aggregate supply curve,an increase in aggregate demand results in an increase in (a) price level only (b)real GDP only(c) neither price level nor real GDP(d)nominal GDP only (e)price l c语言acm题 acm刷题是什么意思 阶乘所得结果的位数怎么算?这是一道acm编程题. acm的一道c语言问题 resulting in an increase in inflation 这个词组,increase是名词吗 用an定冠词RT This deforestation is caused by an increase in agriculture.increase 前为什么有 an 一道数学题,已知线段AB=acm,A1平分AB,A2平分AA1,A3平分AA2,.,An平分AAn-1,则AAn=()cm. 提供几道Dijkstra算法的ACM水题练习 初二的一道证明题,才华横溢的各位拜托了~(有图)如图1所示,点C为线段AB上一点,△ACM和△CBN是等边三角形,直线AN、MC交于点E,直线BM、CN交于点F. (1)求证:AN=BM; (2)求证:△CEF是等边 一道很简单的ACM题,求大神看看我错在哪儿了,C++You must have heard of an ancient encryption called Caesar cipher or 'shift cipher'.That is,given the plaintext and a number D,you should replace every character c in the plaintext with an 求助一道ACM题一道很简单的ACM题目,题在这里我写的代码如下:#include using namespace std;int main(){int n,m[30];cin>>n;for(int i=0;i=0;j--){cout ACM的一道题,但是数字大了,过不了!.2的64次方应该用什么类型保存! 英语翻译an increase in the number of people committing suicide