TOPIC

Translation in English

Shykat asked 6 years ago

URI Online Judge | 2460 Row By OBI - Brazilian Olympiad of Informatics 2014 BRBrazil

Timelimit: 1 With the closeness of the World Cup, the flow of people in the queues to buy tickets has increased considerably. As the queues grow larger, less patient people tend to give up buying tickets and end up leaving the queues, thus freeing up other people. When a person leaves the queue, all the people behind her take a step forward, so there is never a vacant space between two people. The queue initially contains N people, each with a different identifier. Johnny knows her initial state and the orderly identifiers of the people who left the queue. Knowing that after the initial state no person ever got in the queue, Johnny wants to know the final status of the queue.

Input The first line contains an integer N (1 ≤ N ≤ 50000) representing the number of people initially in the queue. The second line contains N integers representing the identifiers of the people in the queue. The first identifier corresponds to the identifier of the first person in the queue. It is guaranteed that two different people do not have the same identifier. The third line contains an integer M (1 ≤ M ≤ 50000 and M < N ) representing the number of people who left the queue. The fourth line contains Mintegers representing the identifiers of the people who left the queue (each identifier is between 1 and 100000) in the order in which they left. It is guaranteed that the same identifier does not appear twice in this list.

Output Your program should print an entire N - M content line with the identifiers of people who have remained queued in order of arrival.

Input Examples Output Examples

8

5 100 9 81 70 33 2 1000

3

9 33 5 100 81 70 2 1000

4

10 9 6 3

1

3 10 9 6

OBI - Brazilian Olympics of Informatics 2014 Phase 1 Junior Level

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.