문제 전문을 여기에 입력.
입력 조건을 여기에 입력.
문제에서 주어지는 테스트 케이스와 예상 결과를 여기에 입력
import java.util.*;
import java.io.*;
public class Main {
private static int[] counter = new int[8001];
public static void solution() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
Map<String, Double> grades = Map.of(
"A+", 4.5,
"A0", 4.0,
"B+", 3.5,
"B0", 3.0,
"C+", 2.5,
"C0", 2.0,
"D+", 1.5,
"D0", 1.0,
"F", 0.0
);
Double sumOfSubjectGrades = 0.0;
Double credit = 0.0;
String line;
while ((line = br.readLine()) != null) {
String[] subjectGrade = line.split(" ");
if (subjectGrade.length < 3 || subjectGrade[2].equals("P")) {
continue;
}
double subjectCredit = Double.parseDouble(subjectGrade[1]);
double gradeValue = grades.get(subjectGrade[2]);
credit += subjectCredit;
sumOfSubjectGrades += subjectCredit * gradeValue;
}
sb.append(sumOfSubjectGrades / credit);
bw.write(sb.toString());
bw.flush();
bw.close();
br.close();
}
public static void main(String[] args) throws IOException {
solution();
}
}
문제를 분할-정복하기 위해 분할한 내용을 여기에 기술
문제에 대한 알고리즘, 자료구조. 풀이에 대한 내용을 여기에 기술