-->
当前位置:首页 > 题库

PROGRAMMING:Can you insert sort?

Luz5年前 (2021-05-10)题库361
Because of the epidemic, Subaru could only take online lessons at home. On this day, he learned algorithm design. He had doubts about the complexity of the teacher's calculation of insertion and sorting.
So he's going to use mathematical induction to test the complexity himself. We know that to calculate the complexity of insertion sort, we need to calculate the number of times to move each insertion.
But this is a very tedious work, so he found you, he will give the array of each sorting, and then he will ask you how many times you need to move in the first sorting.
###Input format:
The first line contains a positive integer $$t $, indicating that there is a $$t $$group sample $$(1 < = T < = 10)$$
The first line of each group of samples contains two positive integers $$n, M $$indicating that the length of the array given by Subaru is $$n $$, and asking $$M $$(1 < = n, m < = 1E5)$$
The second line contains $$n $$positive integers $$a_ i$$ $$(1<=a_ I < = 1E5) $$as the array to be sorted
Next, $$M $$line, each line has a positive integer, $$p $, indicating that Subaru asked for the number of times to move in the $$p $$order
$$tips: $$sorted from small to large
###Output format:
For each set of samples, $$$needs to output the $$M $$line
An integer for each row, indicating the number of times to move the $$I $$th sorting
###Input example:
Here is a set of inputs. For example:
```in
one
5 4
5 4 3 2 1
one
two
three
four
```
###Output example:
The corresponding output is given here. For example:
```out
0
one
two
three
```







answer:If there is no answer, please comment