#P4309. [TJOI2013] 最长上升子序列

    ID: 3244 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2013线段树各省省选平衡树树状数组天津

[TJOI2013] 最长上升子序列

Description

You are given a sequence that is initially empty. We will insert the numbers 11 through NN into the sequence, each time inserting one number at a specific position. After each insertion, we want to know the length of the current longest increasing subsequence.

Input Format

The first line contains an integer NN, indicating that we will insert 11 through NN into the sequence.

Then follow NN integers. The kk-th number XkX_k indicates that we insert kk at position XkX_k (0Xkk10 \le X_k \le k - 1, 1kN1 \le k \le N).

Output Format

Output NN lines. The ii-th line is the length of the longest increasing subsequence after inserting ii at position XiX_i.

3
0 0 2
1
1
2

Hint

Constraints: For 100%100\% of the testdata, N105N \le 10^5.

Translated by ChatGPT 5