cswork / OA打开练习工作台

AmazonOA #188

Find Requests in Queue

估计中等可在线判题

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

At time 0 all requests join the queue. Each second the front request is processed; it still counts toward that second's size and is removed the following second. Every other request expires and is removed immediately at t=wait[i], and it can only start being served while t<wait[i]. Output the queue length at every second from time 0 until the queue is empty, including the final 0.

输入格式

The first line contains n; the second line contains n waiting deadlines. 1≤n≤100000, 1≤wait[i]≤100000.

输出格式

Output the queue length at each time, separated by spaces; the last value is 0.

样例 1

输入:

4
2 2 3 1

输出:

4 2 1 0

样例 2

输入:

3
4 4 4

输出:

3 2 1 0

样例 3

输入:

4
3 1 2 1

输出:

4 1 0

样例说明

The three examples give 4 2 1 0, 3 2 1 0 and 4 1 0.