- Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathEquality.java
26 lines (24 loc) · 769 Bytes
/
Equality.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//problem: https://codeforces.com/problemset/problem/758/A
importjava.util.Scanner;
publicclassEquality{
publicstaticintfindGreatest(String[] arr){
intmax = Integer.MIN_VALUE;
for(Stringele: arr){
if(Integer.parseInt(ele) > max){
max = Integer.parseInt(ele);
}
}
returnmax;
}
publicstaticvoidmain(String[] args){
ScannersObj = newScanner(System.in);
intn = Integer.parseInt(sObj.nextLine());
String[] input = sObj.nextLine().split(" ");
intgreatest = findGreatest(input);
inttotal = 0;
for(Stringele: input){
total += greatest - Integer.parseInt(ele);
}
System.out.println(total);
}
}