Two Kilers
Time limit10sMemory limit512 MB
Given an array with point updates, print after each update the length of its longest strictly increasing subsequence, capped at k.
- Level
Medium7 of 10
- Topics
- Segment tree, Dynamic programming, Binary search
- Solved
- No attempts yet
Statement
Jurek Kiler, the main character of the Polish movie Two Kilers, receives regular deliveries of gold boxes. The value of the -th delivery is , the total value of the gold boxes inside it.
Recently Jurek has become concerned that the values of the deliveries are falling. To check this, he defined a measure for a sequence of deliveries called the disorder of the sequence. For an integer sequence , the disorder is the length of its longest strictly increasing subsequence. Formally, it is the largest integer such that there are indices with .
If the disorder is at least , Jurek considers his concern unfounded and does not need the exact value. Some gold boxes are stolen, and some arrive late in large batches, so the delivery values can change. After each change, compute the disorder, or output if the disorder is at least .
Input
The first line contains one integer , the number of test cases.
Each test case starts with a line containing two integers and , the number of deliveries and the parameter . The next line contains integers , the initial delivery values. The next line contains one integer , the number of value changes. Each of the following lines contains two integers and , meaning that .
Output
For each test case, output lines, each containing one natural number. If the disorder after the -th change is , output on the -th line.
Constraints