Skip to content

Commit a50dbed

Browse files
committed
[level 1] Title: 모의고사, Time: 1.19 ms, Memory: 84.1 MB -BaekjoonHub
1 parent d895069 commit a50dbed

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

프로그래머스/1/42840. 모의고사/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 성능 요약
66

7-
메모리: 86.1 MB, 시간: 96.77 ms
7+
메모리: 84.1 MB, 시간: 1.19 ms
88

99
### 구분
1010

@@ -16,7 +16,7 @@
1616

1717
### 제출 일자
1818

19-
2025년 05월 14일 18:32:48
19+
2025년 05월 14일 18:39:43
2020

2121
### 문제 설명
2222

프로그래머스/1/42840. 모의고사/모의고사.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
import java.util.*;
22

33
class Solution {
4+
5+
//각 수포자가 기재한 답 배열 선언
46
static int[] first = {1,2,3,4,5};
57
static int[] second = {2,1,2,3,2,4,2,5};
68
static int[] third = {3,3,1,1,2,2,4,4,5,5};
79

810
static List<Integer> al = new ArrayList<>();
911

10-
public Integer[] solution(int[] answers) {
12+
public List<Integer> solution(int[] answers) {
1113

1214
int first_cnt = calc(first, answers);
1315
int second_cnt = calc(second, answers);
1416
int third_cnt = calc(third, answers);
15-
16-
int max = Math.max(first_cnt,second_cnt);
17-
max = Math.max(max, third_cnt);
1817

18+
// 가장 많이 맞은 갯수 구하기
19+
int max = Math.max(Math.max(first_cnt,second_cnt), third_cnt);
20+
21+
// 가장 많은 문제를 맞힌 사람 구하기(동점자 고려)
1922
if(first_cnt == max){
2023
al.add(1);
2124
}
@@ -26,17 +29,16 @@ public Integer[] solution(int[] answers) {
2629
al.add(3);
2730
}
2831

29-
Integer[] answer = new Integer[al.size()];
30-
31-
return al.toArray(answer);
32+
return al;
33+
// Integer[] answer = new Integer[al.size()];
34+
// return al.toArray(answer);
3235
}
3336

3437
int calc(int[] a, int[] b){
3538
int cnt = 0;
3639

40+
//정답과 기재한 답 비교후 맞은 갯수 구하기
3741
for(int i=0; i<b.length; i++){
38-
System.out.println(b[i] + " " + a[i%a.length]);
39-
4042
if(b[i] == a[i%a.length]){
4143
cnt++;
4244
}

0 commit comments

Comments
 (0)