반응형
import java.util.Arrays;
import java.util.Scanner;
public class score {
public static void main(String[] args) {
// 1. N은 항상 10의 배수이며, 10이상 100이하의 정수이다. (10 ≤ N ≤ 100)
// 2. K는 1 이상 N 이하의 정수이다. (1 ≤ K ≤ N)
// 3. K 번째 학생의 총점과 다른 학생의 총점이 동일한 경우는 입력으로 주어지지 않는다.
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
sc.nextLine();
String[] records = {"D0","C-","C0","C+","B-","B0","B+","A-","A0","A+" };
for(int test_case = 1; test_case <= T; test_case++)
{
int student_count = sc.nextInt();
int individual_student =sc.nextInt();
double[] grades = new double[student_count];
double findScore;
String result = "";
for (int i = 0; i <student_count ; i++) {
int middleTest = sc.nextInt();
int finalTest = sc.nextInt();
int assignment= sc.nextInt();
double totalScore = middleTest * 0.35 + finalTest * 0.45 + assignment * 0.2;
grades[i] = totalScore;
}
findScore = grades[individual_student - 1];
Arrays.sort(grades);
for (int i = 0; i < student_count; i++) {
if (grades[i] == findScore){
result = records[i / (student_count / 10)];
}
}
// System.out.print(Arrays.toString(grades));
System.out.println("#"+test_case + " " + result);
}
}
}
반응형
'알고리즘' 카테고리의 다른 글
[SWEA][D2] 2001. 파리 퇴치 Java (0) | 2025.06.01 |
---|---|
[SWEA][D2] 1979. 어디에 단어가 들어갈 수 있을까 Java (0) | 2025.06.01 |
[SWEA][D2] 1984. 중간 평균값 구하기 Java (0) | 2025.06.01 |
[SWEA][D2] 1986. 지그재그 숫자 Java (0) | 2025.06.01 |
[SWEA][D2] 2005. 파스칼의 삼각형 Java (0) | 2025.05.31 |