나의 경우 count[scores[i]] ++;이 이해가 되지않았었다.
고수님들께 여쭤본 끝에 드디어 이해할 수 있었는데..
count배열은 해당 점수를 받은 사람이 몇명인지 그 숫자가 들어가는 배열이었다...
가등님 싸부님 감사합니다..!
몇시간동안 고민해서 못풀고... 검색해서 겨우 어느정도 이해가는거 찾아서 했는데도 잘 안되었는데... 결국 이해해서 다행이다.
그래도 그나마 위안이되는건, 내가 끝까지 못했을뿐 푸는 방식은 내가 생각했던것이랑 같다는것이다. ㅠㅠㅠㅠ
오늘 드디어 SWEA D1,D2를 어찌저찌 다 풀긴 풀었는데.. 언제 내것으로 만들지...허어
package oSWExpertAcademy;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class D2_1204 {
public static void main(String[]args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
int testCase = Integer.parseInt(br.readLine());
for(int tc=1; tc<=testCase; tc++) {
int tcNum = Integer.parseInt(br.readLine());
int maxScore = 0;
int scores[] = new int[1000];
//해당 점수를 받은 사람의 수를 배열에 입력해준다
int count[] = new int[101];
StringTokenizer st = new StringTokenizer(br.readLine());
for(int i=0; i<1000; i++) {
//점수를 입력한다
scores[i] = Integer.parseInt(st.nextToken());
count[scores[i]] ++;
}
for(int i=0; i<count.length-1; i++) {
//count[최고점]이 count[i]보다 작으면 최고점이 갱신된다
if(count[maxScore] <= count[i]) {
maxScore = i;
}
}
System.out.println("#"+tc+" "+maxScore);
}
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
'Java > SW Expert Academy' 카테고리의 다른 글
1284. 수도 요금 경쟁 (0) | 2021.01.12 |
---|---|
1288. 새로운 불면증 치료법 (0) | 2021.01.12 |
1928. Base64 Decoder (0) | 2021.01.12 |
1940. 가랏! RC카! (0) | 2021.01.11 |
1945. 간단한 소인수분해 (0) | 2021.01.11 |
댓글