KuZ the Position
Time Limit: 1.0 s
Memory Limit: 256.0 MB
Description
You are given an array A and the length of the array is N. You are also given a positive integer Q which represents the query. In each query you are given a positive integer X, you have to find out the minimum value in the array and print the position of this value. then you have to replace this value with X.
NOTE: It is guaranteed that the array will be unique.
Input
The first line contains an integer value N(1 ≤ N ≤ \(10^5\))
The second line contais N integers \(A_1\) , \(A_2\) ,,, \(A_N\) (1 ≤ \(A\) ≤ \(10 ^ {9}\))
The third line contains an integer value Q(1 ≤ Q ≤ \(10^5\)) and each query you will get a positive integer X(1 ≤ X ≤ \(10^9\))
Output
For each query print the position of the minimum value of the array.
Sample
Input | Output |
---|---|
|
|
The original array in the first test case is {5, 3, 1, 2, 4}.
Since x = 6 in the initial query, it will be replaced with the minimum value at position 3 in the current state of this array, where the minimum value is 1. As a result, the updated array will be {5, 3, 6, 2, 4}, and the output will be 3.
Since x = 7 in the second query, it will be replaced with the minimum value at position 4 in the current state of the array, where the minimum value is 2. As a result, the updated array will be {5, 3, 6, 7, 4}, and the output will be 4.
Information
- ID
- 1086
- Difficulty
- 4
- Category
- Sorting , Beginners Click to Show
- Tags
- # Submissions
- 159
- Accepted
- 69
- Accepted Ratio
- 43%
- Uploaded By
Related
In following contests: