-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathURI1104ExchangingCards.java
More file actions
43 lines (38 loc) · 1.38 KB
/
URI1104ExchangingCards.java
File metadata and controls
43 lines (38 loc) · 1.38 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
43
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1104">Exchanging
* Cards</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1104ExchangingCards {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
String l;
int cards1, cards2;
while (!(l = in.readLine()).equals("0 0")) {
Set<String> c1 = new HashSet<>(Arrays.asList(in.readLine().split("\\s")));
Set<String> c2 = new HashSet<>(Arrays.asList(in.readLine().split("\\s")));
cards1 = 0;
cards2 = 0;
for (Iterator<String> iterator = c1.iterator(); iterator.hasNext();) {
String a = iterator.next();
cards1 += (!c2.contains(a) ? 1 : 0);
}
for (Iterator<String> iterator = c2.iterator(); iterator.hasNext();) {
cards2 += (!c1.contains(iterator.next()) ? 1 : 0);
}
out.println(cards1 > cards2 ? cards2 : cards1);
}
out.close();
}
}