forked from wotjd4305/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswe5603.java
More file actions
49 lines (34 loc) · 943 Bytes
/
swe5603.java
File metadata and controls
49 lines (34 loc) · 943 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.ArrayList;
import java.util.Scanner;
public class swe5603 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
int idx = 1;
ArrayList<Integer> AL = new ArrayList<>();
//테스트케이스
for(int t=0; t<T; t++) {
int N = sc.nextInt();
int mid = 0;
int answer = 0;
//값받기
for(int i=0; i<N; i++)
{
AL.add(sc.nextInt());
}
//중간값구하기
for(int i=0; i<N; i++)
{
mid += AL.get(i);
}
mid /= N;
for(int i : AL)
{
if((i - mid) > 0)
answer += (i-mid);
}
AL.clear();
System.out.println("#" + (idx++) + " " + answer);
}
}
}