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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education