cswork / OAOpen practice workspace

RobloxOA #5

House Destruction — Count Segments After Each Removal

Estimated MediumJudge-ready

Topics (AI-labelled)HashingSimulation

You are given distinct initial house coordinates and distinct demolition queries; each query demolishes one currently existing house. Output the number of remaining contiguous house segments after each demolition.

Input

The first line contains n q; the second line contains n initial coordinates; the third line contains q demolition coordinates. 1≤n≤200000, 1≤q≤n; coordinates range over −10^9..10^9, and every query is one of the initial houses, with no repeats.

Output

Output the number of contiguous segments after each demolition, in order, separated by spaces.

Example 1

Input:

6 6
1 2 3 6 7 9
6 3 7 2 9 1

Output:

3 3 2 2 1 0

Example 2

Input:

1 1
0
0

Output:

0

Example 3

Input:

4 2
-3 -2 4 5
-2 4

Output:

2 2

Editorial

Loading solution…