알고리즘 문제풀이/Beakjoon

백준 4909. Judging Olympia (JAVA)

joah.k 2023. 2. 28. 17:11
728x90

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

 

4909번: Judging Olympia

For years, a group of Regional Contest Directors (RCDs) of the ACM International Collegiate Programming Contest (ICPC) have been unsatisfied with the way contest submissions get ranked. The group sees it is academically wrong to emphasize the importance of

www.acmicpc.net

 

Judging Olympia 

 
시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB 546 280 251 52.842%

문제

For years, a group of Regional Contest Directors (RCDs) of the ACM International Collegiate Programming Contest (ICPC) have been unsatisfied with the way contest submissions get ranked. The group sees it is academically wrong to emphasize the importance of program correctness, disregarding the “quality” of the program itself. After all, programming as a profession promotes design, style, maintainability, etc. and not just correctness. The group’s suggestion is to have a panel of six judges. Each judge is assigned the task of grading the submissions based on a particular aspect: 1) Correctness; 2) Robustness; 3) Overall design; 4) Clarity; 5) Coding style; and finally 6) Maintainability. The final grade of a submission would be the average of the six grades it gets.

The old guards of the current ICPC judging style have always responded that it is not possible to impartially judge a program on anything but correctness. How can the ICPC be certain that judging is fair? In other words, how can the ICPC be sure that non of the judges is favoring certain teams and disadvantaging others? Any hint of accusation to the judging process and ICPC loses the prestigious status it worked on for years. (Alright! So they do have a point.) Still, this hasn’t stopped other domains from judging candidates based on subjective metrics. Take for example Gymnastics, or The Nobel Prizes, or even the ACM’s very own Doctoral Dissertation Award. These are all highly respected awards where the winner is selected by judges using subjective metrics. ICPC could use a new judging system based on what is used in gymnastics. Rather than having each judge grade a certain aspect of the program, each of the six judges would assign an overall grade (out of ten) based on all of the six metrics mentioned above. To enforce impartiality, the final grade of a submission would be calculated as the average of all the grades after deleting two grades: The highest and the lowest. Any judge that favors a certain team (and assigns them an undeserved high grade,) risks the possibility of that grade being dismissed. Similarly, any judge that attempts to disadvantage a team by assigning them a low grade faces a similar risk.

Write a program to print the final grade of a submission.

입력

Your program will be tested on one or more test cases. Each test case is described on a single input line listing the grades of the judges. The end of the test cases is identified with a dummy test case with all the grades being zero.

출력

For each test case, print the grade on a separate line (without unnecessary decimal points and/or zeros.)

 

예제 입력 1 복사

8 8 8 4 4 4
8 8 6 4 4 3
0 0 0 0 0 0

 

예제 출력 1 복사

6
5.5
 

 

 


풀이 :  최대와 최소 점수를 제외한 나머지 점수들의 평균을 구하는 문제. 

출력 형식 (4로 나누어 떨어지면 소수점 없이 출력, 나누어 안 떨어지면 소수점 첫번째까지 구하는) 부분에서 조금 헤맸다. 

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Beakjoon4909 {
    // 백준 4909. Judging Olympia
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        while (true){
            StringTokenizer st = new StringTokenizer(br.readLine());
            double [] arr = new double[6];

            double sum = 0;
            for(int i=0; i<6; i++){
                arr[i] = Double.parseDouble(st.nextToken());
                sum += arr[i];
            }

            if(sum==0) break;

            // 값을 순차적으로 정렬
            Arrays.sort(arr);
            // 최소 최대값을 제외한 값들을 더함
            sum -= arr[0] + arr[5];

            if(sum%4 == 0) System.out.printf("%.0f\n", sum/4); // 첫 번째 소수점자리수에서 반올림
            else System.out.println(sum/4);
        }
    }
}
728x90