Problem Solving/Baekjoon
[백준] 10527 Judging Troubles - Data Structure / Java
graycode
2023. 6. 29. 20:21
• 문제 링크
10527번: Judging Troubles
The NWERC organisers have decided that they want to improve the automatic grading of the submissions for the contest, so they now use two systems: DOMjudge and Kattis. Each submission is judged by both systems and the grading results are compared to make s
www.acmicpc.net
• 풀이 과정
• 풀이 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.HashMap;
import java.util.Map;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = Integer.parseInt(br.readLine());
Map<String, Integer> map = new HashMap<>();
String key;
for (int i = 0; i < n; i++)
map.put(key = br.readLine(), map.getOrDefault(key, 0) + 1);
int cnt = 0;
while (n-- > 0) {
key = br.readLine();
if (map.containsKey(key) && map.get(key) > 0) {
map.put(key, map.get(key) - 1);
cnt++;
}
}
bw.write(String.valueOf(cnt));
bw.flush();
}
}