Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/65536 K (Java/Others)
Today CodeFamer is going to cut trees.There are?N?trees
standing in a line. They are numbered from?1?to?N.
The tree numbered?i?has
We say that two uncutted trees whose numbers are?x?and?y?are
in the same block if and only if they are fitting in one of blow rules:
1)x+1=y or y+1=x;
2)there exists an uncutted tree which is numbered?z,
in the same block with?z,
also in the same block with?z.
Now CodeFamer want to cut some trees whose height is not larger than some value, after those trees are cut, how many tree blocks are there?
Multi test cases (about?15).
For each case, first line contains two integers?N?and
by exactly one space, N indicates there are?N?trees,?Q?indicates
In the following?N?lines,
there will appear?h,h,h,…,h[N]?
? ? ? which indicates the height of the trees.
In the following?Q?lines,
there will appear?q,q,q,…,q[Q]?
? ? ? ? which indicates CodeFamer’s queries.
Please process to the end of file.
, ?Q ? ??≤?50000
output the number of tree block after CodeFamer cut the trees whose height are not larger than?q[i].
In this test case, there are 3 trees whose heights are 5 2 3.
For the query 6, if CodeFamer cuts the tree whose height is not large than 6, the height form of left trees are -1 -1 -1(-1 means this tree was cut). Thus there is 0 block.
For the query 2, if CodeFamer cuts the tree whose height is not large than 2, the height form of left trees are 5 -1 3(-1 means this tree was cut). Thus there are 2 blocks.