Problem K
Knot Knowledge

Sonja the scout is taking a test to see if she knows all the knots a scout is supposed to know. The Scout’s Big Book of Knots has descriptions of $1\, 000$ different knots, conveniently numbered from $1$ to $1\, 000$. For the test, Sonja needs to learn a specific set of $n$ of these knots. After some intense studying, she has learned all except one of them, but she has forgotten which knot she does not yet know.

Given the list of knots Sonja needs to learn, and the ones she has learned so far, find the remaining knot to learn.


The first line of input consists of an integer $n$ ($2 \le n \le 50$), the number of knots Sonja needs to learn. This is followed by a line containing $n$ distinct integers $x_1, \ldots , x_ n$ ($1 \le x_ i \le 1\, 000$), the knots that Sonja needs to learn. Finally, the last line contains $n-1$ distinct integers $y_1, \ldots , y_{n-1}$ ($1 \le y_ i \le 1\, 000$), the knots that Sonja has learned so far. You may assume that each knot Sonja has learned is one of the $n$ knots she was supposed to learn.


Output the number of the remaining knot that Sonja needs to learn.

Sample Input 1 Sample Output 1
1 2 4 3
4 2 3
Sample Input 2 Sample Output 2
10 101 999 1
1 999 101
CPU Time limit 1 second
Memory limit 1024 MB
Bergur Snorrason
Source Nordic Collegiate Programming Contest (NCPC) 2021
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in