Array Delete Element
Array Deletion
Mark has an array , A of N elements. He Performs Q queries in it. In each query, he chooses an index I(0-based)
and does the following :
for j=I+1 to N:
if A[j] < A[I]:
A[j] = 0
you need to print what array A looks like after processing all the Q queries.
Note: The queriesare not independentof each other i.e. you need to use the changes array A, for each Query.
Constraints
1 <= T <= 10
1 <= N <= 10^5
1 <= A <= 10^9
1 <= Q <= 10^5
Input
The first line of input has an integer T,denoting the number of test cases. Each test case will consist of 3 lines .
The first line contains 2 space seperated integer, N and Q, denoting the number of element in the arrayand number of queries.
2nd line will have N space seperated integersdenoting the elements in the initial array A.
3rd line will have Q space seperated integers denoting the chosen index in the each query.
Output:
For each test case, output in a seperate line, N space seperated integer denoting the final array A.
Sample Input Output
2
5 2
4 3 4 3 2 4 3 4 0 0
3 2
3 1
3 2 1 3 2 1
2