문제

https://www.acmicpc.net/problem/1546


문제 풀이

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
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int max = Integer.MIN_VALUE;
        double sum = 0;
        int[] tmp = new int[n];
        double[] score = new double[n];

        for (int i = 0; i < n; i++) {
            tmp[i] = sc.nextInt();

            if (max < tmp[i]) {
                max = tmp[i];
            }
        }


        for (int i = 0; i < n; i++) {
            score[i] = (double) tmp[i] / max * 100;
            sum+=score[i];
        }

        System.out.println(sum/n);
    }
}

카테고리:

업데이트:

댓글남기기