please. Correct and detail answer will upvoted else downvote. There are one feline, k mice, and one opening on an arrange line. The feline is situated at the point 0, the opening is situated at the point n. All mice are situated between the feline and the opening: the I-th mouse is situated at the point xi (0
C++ code please. Correct and detail answer will upvoted else downvote.
There are one feline, k mice, and one opening on an arrange line. The feline is situated at the point 0, the opening is situated at the point n. All mice are situated between the feline and the opening: the I-th mouse is situated at the point xi (0<xi<n). At each point, numerous mice can be found.
In one second, the accompanying occurs. To begin with, precisely one mouse moves to one side by 1. On the off chance that the mouse arrives at the opening, it stows away (for example the mouse will no more move to any point and won't be eaten by the feline). Then, at that point (after that the mouse has completed its turn) the feline moves to one side by 1. In the event that at the new feline's position, a few mice are found, the feline eats them (they can not move after that). The activities are performed until any mouse hasn't been covered up or isn't eaten.
At the end of the day, the primary move is made by a mouse. In the event that the mouse has arrived at the opening, it's saved. Then, at that point, the feline takes action. The feline eats the mice situated at the pointed the feline has reached (if the feline has arrived at the opening, it eats no one).
Each second, you can choose a mouse that will take action. What is the greatest number of mice that can arrive at the opening without being eaten?
Input
The principal line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow.
Each experiment comprises of two lines. The principal line contains two integers n and k (2≤n≤109, 1≤k≤4⋅105). The subsequent line contains k integers x1,x2,… xk (1≤xi<n) — the underlying directions of the mice.
It is ensured that the amount of all k given in the input doesn't surpass 4⋅105.
Output
For each experiment output on a different line an integer m (m≥0) — the most extreme number of mice that can arrive at the opening without being eaten
Step by step
Solved in 3 steps with 1 images