-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBJAlgo_2002.java
More file actions
33 lines (28 loc) · 893 Bytes
/
Copy pathBJAlgo_2002.java
File metadata and controls
33 lines (28 loc) · 893 Bytes
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
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class BJAlgo_2002 {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int result = 0;
int N = Integer.parseInt(br.readLine());
Map<String, Integer> cars = new HashMap<>();
for(int i = 0; i < N; i++) {
String car = br.readLine();
cars.put(car, i);
}
for(int i = 0; i < N; i++) {
String car = br.readLine();
int num = cars.get(car);
cars.remove(car);
for(int j : cars.values()) {
if (num > j) {
result += 1;
break;
}
}
}
System.out.println(result);
}
}