• 문제 링크
https://www.acmicpc.net/problem/32953
• 풀이 코드
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));
Map<Integer, Integer> map = new HashMap<>();
int n = read(), m = read();
while (n-- > 0) {
int k = read(), i;
while (k-- > 0) map.put(i = read(), map.getOrDefault(i, 0) + 1);
}
int cnt = 0;
for (int v : map.values()) if (v >= m) cnt++;
bw.write(String.valueOf(cnt));
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' 카테고리의 다른 글
[백준] 10209 Theseus and the Minotaur - Data Structure / Java (0) | 2025.01.19 |
---|---|
[백준] 32979 아파트 - Data Structure / Java (0) | 2025.01.18 |
[백준] 1408 24 - Implementation / Java (0) | 2025.01.16 |
[백준] 10988 팰린드롬인지 확인하기 - Implementation / Java (0) | 2025.01.15 |
[백준] 1284 집 주소 - Implementation / Java (0) | 2025.01.14 |
댓글