SSONG Cloud
[SWEA] 1204 최빈수 구하기 본문
반응형
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int num = 0; // 테스트 케이스 숫자
int score = 0;
int[] scores = new int[1000];
int T = sc.nextInt();
for(int i = 0; i < T; i++) {
int[] modes = new int[101];
int mode = 0;
num = sc.nextInt();
for (int j = 0; j < 1000; j++) {
scores[j] = sc.nextInt();
modes[scores[j]]++;
}
for(int k = 0; k < 101; k++) {
if(modes[k] >= mode) {
mode = modes[k];
score = k;
}
}
System.out.println("#" + ( i + 1 ) + " " + score);
}
}
}
반응형
'Algorithm > SW Expert Academy' 카테고리의 다른 글
[SWEA] 2005 파스칼의 삼각형 (0) | 2021.01.24 |
---|---|
[SWEA] 1974 수도쿠 검증 (0) | 2021.01.24 |
[SWEA] 1284 수도 요금 경쟁 (0) | 2021.01.24 |
[SWEA] 간단한 369게임 (0) | 2021.01.24 |
[SWEA] 1289 원재의 메모리 복구하기 (0) | 2021.01.24 |
Comments