cswork / OA打开练习工作台

RobloxOA #5

House Destruction — Count Segments After Each Removal

估计中等可在线判题

考点(AI 标注)哈希计数模拟/实现

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.

输入格式

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 the number of contiguous segments after each demolition, in order, separated by spaces.

样例 1

输入:

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

输出:

3 3 2 2 1 0

样例 2

输入:

1 1
0
0

输出:

0

样例 3

输入:

4 2
-3 -2 4 5
-2 4

输出:

2 2