Codeforces Round 162 (Div. 1)
E
Roadside Trees
Codeforces
3000
原题
← D→
翻译中…

Squirrel Liss loves nuts. Liss asks you to plant some nut trees.

翻译中…

There are $*n*$ positions (numbered 1 to $*n*$ from west to east) to plant a tree along a street. Trees grow one meter per month. At the beginning of each month you should process one query. The query is one of the following types:

翻译中…
  1. Plant a tree of height $*h*$ at position $*p*$.
  2. Cut down the $*x*$-th existent (not cut) tree from the west (where $*x*$ is 1-indexed). When we cut the tree it drops down and takes all the available place at the position where it has stood. So no tree can be planted at this position anymore.
翻译中…

After processing each query, you should print the length of the longest increasing subsequence. A subset of existent trees is called an increasing subsequence if the height of the trees in the set is strictly increasing from west to east (for example, the westmost tree in the set must be the shortest in the set). The length of the increasing subsequence is the number of trees in it.

翻译中…

Note that Liss don't like the trees with the same heights, so it is guaranteed that at any time no two trees have the exactly same heights.

翻译中…

Input

翻译中…

The first line contains two integers: $*n*$ and $*m*$ ($1  ≤ *n* ≤ 10^{5}; 1 ≤ *m* ≤ 2·10^{5}$) — the number of positions and the number of queries.

翻译中…

Next $*m*$ lines contains the information of queries by following formats:

翻译中…
  • If the $*i*$-th query is type 1, the $*i*$-th line contains three integers: 1, $*p*_{*i*}$, and $*h*_{*i*}$ ($1 ≤ *p*_{*i*} ≤ *n*, 1 ≤ *h*_{*i*} ≤ 10$), where $*p*_{*i*}$ is the position of the new tree and $*h*_{*i*}$ is the initial height of the new tree.
  • If the $*i*$-th query is type 2, the $*i*$-th line contains two integers: 2 and $*x*_{*i*}$ ($1 ≤ *x*_{*i*} ≤ 10$), where the $*x*_{*i*}$ is the index of the tree we want to cut.
翻译中…

The input is guaranteed to be correct, i.e.,

翻译中…
  • For type 1 queries, $*p*_{*i*}$ will be pairwise distinct.
  • For type 2 queries, $*x*_{*i*}$ will be less than or equal to the current number of trees.
  • At any time no two trees have the exactly same heights.
翻译中…

In each line integers are separated by single spaces.

翻译中…

Output

翻译中…

Print $*m*$ integers — the length of the longest increasing subsequence after each query. Separate the numbers by whitespaces.

翻译中…

Note

翻译中…

States of street after each query you can see on the following animation:

翻译中…

image

翻译中…

If your browser doesn't support animation png, please see the gif version here: http://212.193.37.254/codeforces/images/162/roadtree.gif

翻译中…

样例

Input #1
4 6
1 1 1
1 4 4
1 3 4
2 2
1 2 8
2 3
Output #1
1
2
3
2
2
2
InputCopy OutputCopy
题目信息
题号
264E
时间限制
5 s
内存限制
256 MB
标签
数据结构
动态规划

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