-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ_1269.java
More file actions
34 lines (29 loc) ยท 1.36 KB
/
Copy pathBOJ_1269.java
File metadata and controls
34 lines (29 loc) ยท 1.36 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
// BOJ - 1269
// Problem Sheet - https://www.acmicpc.net/problem/1269
import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(bf.readLine());
Set<Integer> union = new HashSet<>(); // ๋ ์งํฉ์ ํฉ์งํฉ ์์๋ฅผ ์ ์ฅ
Set<Integer> intersection = new HashSet<>(); // ๋ ์งํฉ์ ๊ต์งํฉ ์์๋ฅผ ์ ์ฅ
// ์งํฉ์ ์ ๋ณด๋ฅผ ์
๋ ฅ๋ฐ์ ๊ตฌ์ฑํ๋ ๋ถ๋ถ
// ํต์ฌ - ๋ ์งํฉ์ ํฉ์งํฉ์์ ๊ต์งํฉ๋ง ๋นผ๋ฉด ๋จ
int numberOfA = Integer.parseInt(st.nextToken()); // ์งํฉ A์ ์์์ ๊ฐฏ์
int numberOfB = Integer.parseInt(st.nextToken()); // ์งํฉ B์ ์์์ ๊ฐฏ์
st = new StringTokenizer(bf.readLine());
for(int i=0 ; i<numberOfA ; i++)
union.add(Integer.parseInt(st.nextToken()));
st = new StringTokenizer(bf.readLine());
for(int i=0 ; i<numberOfB ; i++) {
int element = Integer.parseInt(st.nextToken());
if(union.contains(element))
intersection.add(element);
union.add(element);
}
System.out.println(union.size() - intersection.size());
bf.close();
System.exit(0);
}
}