CF264E Roadside Trees <线段树>
Problem
Roadside Trees
Description
Squirrel Liss loves nuts. Liss asks you to plant some nut trees.
There are positions (numbered 1 to 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:
- Plant a tree of height at position .
- Cut down the existent (not cut) tree from the west (where 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: and – the number of positions and the number of queries.
Next lines contains the information of queries by following formats:
- If the query is type 1, the line contains three integers: 1, , and , where is the position of the new tree and is the initial height of the new tree.
- If the query is type 2, the line contains two integers: 2 and , where the is the index of the tree we want to cut.
The input is guaranteed to be correct, i.e., - For type 1 queries, will be pairwise distinct.
- For type 2 queries, 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 integers – the length of the longest increasing subsequence after each query. Separate the numbers by whitespaces.