-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparking.java
More file actions
36 lines (27 loc) · 925 Bytes
/
Copy pathparking.java
File metadata and controls
36 lines (27 loc) · 925 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
import java.util.Scanner;
public class parking {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int cases = sc.nextInt();
int[] output = new int[cases];
for (int i = 0; i < cases; i++) {
int shops = sc.nextInt();
int[] dist = new int[shops];
for (int j = 0; j < shops; j++) {
dist[j] = sc.nextInt();
}
//kleinste Zahl
int klein=dist[0];
int groeste=dist[0];
for (int j = 0; j < shops; j++) {
if(klein<dist[j])klein = dist[j];
if(groeste>dist[j])groeste=dist[j];
}
int erg = (groeste-klein)*2;
output[i] = -erg;
}//end for
for (int u = 0; u < cases; u++) {
System.out.println(output[u]);
}
}
}