본문 바로가기
알고리즘 & 자료구조/백준

백준 4344

by 신재권 2021. 7. 8.
import java.util.Scanner;

public class Main4344 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int C = sc.nextInt();
		String[] ratio = new String[C];
		double[] aver = new double[C];
		int sum = 0;
		int cnt = 0;
		for (int i = 0; i < C; i++) {
			int N = sc.nextInt();
			int[] score = new int[N];
			for (int j = 0; j < N; j++) {
				score[j] = sc.nextInt();
				sum += score[j];
				if (j == N - 1) {
					aver[i] = (double) sum / N;
					sum = 0;
					for (int k = 0; k < N; k++) {
						if (score[k] > aver[i]) {
							cnt++;
						}
						ratio[i] = String.format("%.3f", (double) cnt / N
								* 100.0);
					}
					cnt = 0;
				}
			}
		}
		for (int i = 0; i < C; i++)
			System.out.println(ratio[i] + "%");
	}
}

'알고리즘 & 자료구조 > 백준' 카테고리의 다른 글

백준 4673  (0) 2021.07.09
백준 15596  (0) 2021.07.09
백준 1546  (0) 2021.07.08
백준 8958  (0) 2021.07.08
백준 3052  (0) 2021.07.07