문제 이해 각 테스트 케이스마다 학생들의 점수가 주어지는데 해당 점수를 토대로 각 학생들의 등급을 내는 문제이다. 등급을 나누는 기준만 해결하면 쉬운 문제이지만 그 생각이 잘 나지 않아 오래 걸렸다.public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
int test_case = Integer.parseInt(bf.readLine());
String[] credit = {"D0", "C-", "C0", "C+", "B-", "B0", "B+", "A-", "A0", "A+"};
for (int i = 1; i < test_case + 1; i++) {
StringTokenizer st = new StringTokenizer(bf.readLine());
int n = Integer.parseInt(st.nextToken());
int k = Integer.parseInt(st.nextToken());
double[] scores = new double[n];
for (int j = 0; j < n; j++) {
st = new StringTokenizer(bf.readLine());
int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int c = Integer.parseInt(st.nextToken());
scores[j] = a*0.35 + b*0.45 + c*0.2;
}
String ans = "";
double goal = scores[k - 1];
Arrays.sort(scores);
for (int num = 0; num < n; num++) {
if (goal == scores[num]) {
ans = credit[num / (n / 10)];
break;
}
}
System.out.println("#" + i + " " + ans);
}
bf.close();
}
}