第五回日本最強プログラマー学生選手権-予選-(AtCoder Regular Contest 180)
E
LIS and Inversion
AtCoder
⌀ 3549
原题
← DF →
翻译中…

Problem Statement

翻译中…

You are given an integer sequence $A=(A_1,A_2,\cdots,A_N)$ of length $N$. Here, it is guaranteed that $0 \leq A_i < i$ for each $i$.

翻译中…

The score and cost of a permutation $P=(P_1,P_2,\cdots,P_N)$ of $(1,2,\cdots,N)$ are defined as follows:

翻译中…
  • The score of $P$ is the length of a longest increasing subsequence of $P$.
  • The cost of $P$ is the number of integers $i$ ($1 \leq i \leq N$) that satisfy the following condition:
  • There are fewer than $A_i$ integers $j$ such that $j < i$ and $P_j > P_i$.
翻译中…

For each $k=1,2,\cdots,N$, solve the following problem:

翻译中…
  • Find the minimum cost of a permutation $P$ whose score is at least $k$.
翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 250000$
  • $0 \leq A_i < i$
  • All input values are integers.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \cdots A_N

翻译中…

Output

翻译中…

Print the answers for $k=1,2,\cdots,N$ in this order.

翻译中…

样例

Input #1
4
0 1 2 1
Output #1
0 0 1 3
For each $k$, a solution $P$ is as follows: - $k=1$: If $P=(4,2,1,3)$, then $P$ has the score of $2$ and the cost of $0$. - $k=2$: If $P=(4,3,1,2)$, then $P$ has the score of $2$ and the cost of $0$. - $k=3$: If $P=(4,1,2,3)$, then $P$ has the score of $3$ and the cost of $1$. - $k=4$: If $P=(1,2,3,4)$, then $P$ has the score of $4$ and the cost of $3$.
Input #2
3
0 0 0
Output #2
0 0 0
Input #3
5
0 1 2 3 4
Output #3
0 1 2 3 4
Input #4
11
0 0 2 3 4 5 3 7 8 2 10
Output #4
0 0 0 1 2 3 4 5 7 8 9
题目信息

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。