• 문제 링크
https://www.acmicpc.net/problem/7640
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringBuilder sb = new StringBuilder();
Map<Integer, Integer> map = new HashMap<>();
int n, k;
while ((n = read()) != 0) {
while (n-- > 0) map.put(k = read(), map.getOrDefault(k, 0) + 1);
int max = 0;
for (int v : map.values()) max = Math.max(max, v);
sb.append(max).append("\n");
map.clear();
}
bw.write(sb.toString());
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 30063 Pabėgimo kambarys - Data Structure / Java (0) | 2024.11.29 |
---|---|
[백준] 4126 Course Scheduling - Data Structure / Java (0) | 2024.11.28 |
[백준] 24571 Good Groups - Data Structure / Java (0) | 2024.11.26 |
[백준] 4992 Hanafuda Shuffle - Data Structure / Java (0) | 2024.11.25 |
[백준] 24771 Un-bear-able Zoo - Data Structure / Java (0) | 2024.11.24 |
댓글