티스토리 뷰

1983. 조교의 성적 매기기

swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PwGK6AcIDFAUq&categoryId=AV5PwGK6AcIDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

// 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(배열)

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
글 보관함