SWEA_1984) 중간 평균값 구하기

1984) 중간 평균값 구하기 (19.10.04)


문제 링크 (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
36
37
38
39
40
41
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;
        int t = Integer.parseInt(br.readLine());
    
        for(int i=1;i<=t;i++) {
            tk = new StringTokenizer(br.readLine());
            
            int[] arr = new int[10];
            
            for(int j=0;j<10;j++) {
                arr[j] = Integer.parseInt(tk.nextToken());
            }
            
            Arrays.sort(arr);
            
            double s = 0;
            int sum = 0;
            for(int j=1;j<9;j++) {
                sum = sum+arr[j];
                s = s+arr[j];
            }
            
            s = s/8;
            sum = sum/8;
            
            if(s-sum>=0.5) sum = sum+1;
            
            bw.write("#" + i + " " + sum + "\n");
        }
        
        bw.flush();
        bw.close();
    }
}
cs

댓글

이 블로그의 인기 게시물