forked from xtaci/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJudgingTrouble.java
More file actions
42 lines (37 loc) · 1.42 KB
/
Copy pathJudgingTrouble.java
File metadata and controls
42 lines (37 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//https://www.hackerrank.com/contests/2014-icpc-northwestern-european-regional-practice/challenges/judging-troubles
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader ob = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(ob.readLine());
Map<String, Integer> map1 = new HashMap<>();
int other = 0;
for (int i = 0; i < n; i++) {
String item = ob.readLine();
if (map1.get(item) != null) {
map1.put(item, (Integer) map1.get(item) + 1);
} else {
map1.put(item, 1);
}
}
Map<String, Integer> map2 = new HashMap<>();
for (int i = 0; i < n; i++) {
String item = ob.readLine();
if (map2.get(item) != null) {
map2.put(item, (Integer) map2.get(item) + 1);
} else {
map2.put(item, 1);
}
}
int result = 0;
for (Map.Entry<String, Integer> entry : map1.entrySet())
{
Integer value = map1.get(entry.getKey()) != null ? map1.get(entry.getKey()) : 0;
Integer value1 = map2.get(entry.getKey()) != null ? map2.get(entry.getKey()) : 0;
if (value > value1) value = value1;
result += value;
}
System.out.println(result);
}
}