-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0012.java
More file actions
40 lines (33 loc) · 677 Bytes
/
0012.java
File metadata and controls
40 lines (33 loc) · 677 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
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
long sum = 0;
int sa =0;
int sb =0;
int sc =0;
int []a=new int [n];
int []b=new int [n];
int []c=new int [n];
for (int i =0; i<n; i++) {
a[i]=scan.nextInt();
b[i]=scan.nextInt();
c[i]=scan.nextInt();
}
Arrays.sort(a);
Arrays.sort(b);
Arrays.sort(c);
sa = a[(n/2)-1];
sb = b[(n/2)-1];
sc = c[(n/2)-1];
for (int i =0; i<n; i++) {
a[i]=Math.abs(a[i]-sa);
b[i]=Math.abs(b[i]-sb);
c[i]=Math.abs(c[i]-sc);
sum = sum+a[i]+b[i]+c[i];
}
System.out.println(sum);
}
}