• 문제 링크
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();
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 10654 Cow Jog - Data Structure / Java (0) | 2023.06.30 |
---|---|
[백준] 10657 Cow Jog - Data Structure / Java (0) | 2023.06.30 |
[백준] 15233 Final Score - Data Structure / Java (0) | 2023.06.28 |
[백준] 13915 Hot Air Ballooning - Data Structure / Java (0) | 2023.06.27 |
[백준] 5957 Cleaning the Dishes - Data Structure / Java (0) | 2023.06.26 |
댓글