합격자 찾기

han.user();·2023년 4월 9일
0

구름

목록 보기
3/20
post-thumbnail

import java.io.*;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String testnum = br.readLine(); // 시험 본 횟수
        int testnum1 = Integer.parseInt(testnum);
        int count = 0;
        int people1 = 0;

        for (int i = 0; i < testnum1; i++) {
            String people = br.readLine(); // 응시인원 N
            people1 = Integer.parseInt(people);
            String[] sungjuk = br.readLine().split(" "); // 학생들의 성적 공백구분

            int sum = 0;

            int[] sungjuk2 = new int[sungjuk.length];

            for (int k = 0; k < sungjuk.length; k++) {
                int num = Integer.parseInt(sungjuk[k]);
                sungjuk2[k] = num;
                sum += num;
            }
            double avg = (double)sum / people1;

            for (int j = 0; j < sungjuk2.length; j++) {
                if (sungjuk2[j] >= avg) {
                    count++;
                }
            }
            System.out.println(count + "/" + people1);
            count = 0;
        }
    }
}
profile
I'm still hungry.

0개의 댓글