아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Dolls

시간 제한1초메모리 제한1024 MB

요약
인형이 하루에 하나씩 추가될 때, 인접한 크기 차이가 2 이상이 되도록 중첩할 수 있는 최대 부분집합의 크기를 매일 구한다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 동적 계획법, 세그먼트 트리
정답자
아직 제출이 없습니다

문제

Marc is teaching some children about objects with different sizes. To demonstrate this concept, he will be using dolls. These dolls are hollow on the inside, so smaller dolls can be placed inside larger ones.

Each doll has a certain size. A doll of size xx can fit inside another doll of size yy if y−x≥2y - x ≥ 2. In other words, a smaller doll can fit in a larger doll if the difference in size between the larger doll and the smaller doll is at least 22.

A doll stack is formed by selecting some dolls that Marc has and repeatedly fitting the smallest doll into the second smallest doll until only one doll is left. The size of a doll stack is the number of dolls used to create it.

There are n days. On the iith (1≤i≤n1 ≤ i ≤ n) day, Marc will buy a doll of size a\[i]a\[i]. After buying the doll, he will try to construct a doll stack with the maximum number of dolls. Help Marc compute, for each day, the maximum size of a doll stack using the dolls available on that day.

입력

The first line of input contains exactly 11 integer, nn.

The second line contain nn integers a\[1],a\[2],…,a\[n]a\[1], a\[2], \dots , a\[n], representing the sizes of the dolls bought on each of the nn days.

출력

The output should contain nn integers on a single line and separated by spaces. The ii-th integer should be the maximum size of a doll stack using the dolls available on that day.

제한

  • 1≤n≤100,0001 ≤ n ≤ 100\\,000
  • 1≤a\[i]≤500,0001 ≤ a\[i] ≤ 500\\,000

예제3

  1. 예제 1

    입력
    5
    1 2 3 4 5
    
    예상 출력
    1 1 2 2 3
    
  2. 예제 2

    입력
    5
    2 4 6 8 10
    
    예상 출력
    1 2 3 4 5
    
  3. 예제 3

    입력
    5
    3 3 1 3 2
    
    예상 출력
    1 1 2 2 2