cswork / OA打开练习工作台

eBayOA #8

House Density (Longest Contiguous Segment)

估计中等可在线判题

考点(AI 标注)哈希计数并查集

Houses are built one at a time on a number line in the order given by queries, and no two houses share a position. After each build, return the length of the longest run of consecutive integer positions among all houses. The examples in the fixed source and all three language implementations include cases where a new house is adjacent to existing houses, so this site judges by those executable definitions: an insertion may be adjacent to the run on its left, on its right, or on both sides, and it merges with them immediately.

输入格式

The first line contains q (1≤q≤10000), followed by q lines, each containing a position x (−10^9≤x≤10^9); all positions are distinct. q≤10000 keeps the step-by-step output within the problem bank's 65536-byte limit.

输出格式

Output q lines; line i is the length of the longest run of consecutive houses after the first i builds.

样例 1

输入:

3
2
1
3

输出:

1
2
3

样例 2

输入:

4
1
3
0
4

输出:

1
1
2
2

样例说明

Runs are defined over integer positions; a new house only merges with the adjacent left run, the adjacent right run, or both. The answer at each step is the maximum length over all runs.