티스토리 뷰
1983. 조교의 성적 매기기
// 210201
import java.io.*;
import java.util.*;
public class Solution_BJ_1983_조교의성적매기기 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] grade = {"", "D0", "C-", "C0", "C+", "B-","B0", "B+", "A-", "A0", "A+"};
int T = sc.nextInt();
for (int tc=1; tc<=T; tc++) {
int N = sc.nextInt(); // 학생 수
int K = sc.nextInt(); // 성적을 알고 싶은 학생 번호
float[] score = new float[N+1];
float KS = 0;
for (int si=1; si<=N; si++) {
float s = (float) (sc.nextInt()*35 + sc.nextInt()*45 + sc.nextInt()*20)/100;
score[si] = s;
if (si==K) KS = s;
}
Arrays.sort(score);
int ratio = N/10;
String[] res = new String[N+1];
int num = 1;
for (int i=1; i<=10; i++) {
for (int j=1; j<=ratio; j++) {
res[num++] = grade[i];
}
}
for (int i=1; i<=N; i++) {
if (score[i] == KS) {
System.out.println("#" + tc + " " + res[i]);
break;
}
}
}
}
}
1. 답이 이상해서 한참 쳐다보니까 K번째 학생이, K번째로 성적이 높은 학생이 아니라 입력을 K번째로 받은 학생이더라.
2. 자바에서 배열 정렬은 Arrays.sort(배열)
'코딩테스트 > SW Expert' 카테고리의 다른 글
[SWEA] 1206. [S/W 문제해결 기본] 1일차 - View (0) | 2021.02.04 |
---|---|
[SWEA] 1210. [S/W 문제해결 기본] 2일차 - Ladder1 (0) | 2021.02.04 |
[SWEA] 1289. 원재의 메모리 복구하기 (0) | 2021.02.01 |
[SWEA] 1984. 중간 평균값 구하기 (0) | 2021.01.31 |
[SWEA] 1986. 지그재그 숫자 (0) | 2021.01.31 |
댓글