SWEA_1208) Flatten
SWEA
# D3
1208) Flatten (19.10.21)
문제 링크 (SW Expert Academy)
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
|
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer tk;
for(int test=1; test<=10; test++) {
int n = Integer.parseInt(br.readLine());
tk = new StringTokenizer(br.readLine());
int[] map = new int[100];
for(int i=0;i<100;i++) {
map[i] = Integer.parseInt(tk.nextToken());
}
while(n-->0) {
Arrays.sort(map);
map[0] = map[0]+1;
map[99] = map[99]-1;
}
Arrays.sort(map);
int ans = map[99] - map[0];
bw.write("#" + test + " " + ans + "\n");
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기