-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjudging.java
58 lines (45 loc) · 1.02 KB
/
judging.java
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.HashMap;
public class judging {
public static void main(String[] args)
{
Kattio scan = new Kattio(System.in);
int n = scan.getInt();
HashMap<String, Integer> kat = new HashMap<>();
HashMap<String, Integer> dom = new HashMap<>();
for( int i=0; i < n; i++)
{
String lol = scan.getWord();
if(kat.containsKey(lol))
kat.put(lol, kat.get(lol) + 1);
else
kat.put(lol, 1);
}
for( int i=0; i < n; i++)
{
String lol = scan.getWord();
if(dom.containsKey(lol))
dom.put(lol, dom.get(lol) + 1);
else
dom.put(lol, 1);
}
int counter = 0;
if(dom.size() < kat.size())
{
for(String s : dom.keySet())
{
if(kat.containsKey(s))
counter += Math.min(dom.get(s), kat.get(s));
}
}
else
{
for(String s : kat.keySet())
{
if(dom.containsKey(s))
counter += Math.min(dom.get(s), kat.get(s));
}
}
System.out.println(counter);
scan.close();
}
}