make the succession arranged, you might play out the accompanying activity quite a few times you need (perhaps zero): pick an integer I with the end goal that 1≤i≤n and ai>x, and trade the upsides of computer based intelligence and x.    For instance, if a=[0,2,3,5,4], x=1, the accompanying arrangement of activities is conceivable

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 12RP
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

make the succession arranged, you might play out the accompanying activity quite a few times you need (perhaps zero): pick an integer I with the end goal that 1≤i≤n and ai>x, and trade the upsides of computer based intelligence and x. 

 

For instance, if a=[0,2,3,5,4], x=1, the accompanying arrangement of activities is conceivable: 

 

pick i=2 (it is conceivable since a2>x), then, at that point, a=[0,1,3,5,4], x=2; 

 

pick i=3 (it is conceivable since a3>x), then, at that point, a=[0,1,2,5,4], x=3; 

 

pick i=4 (it is conceivable since a4>x), then, at that point, a=[0,1,2,3,4], x=5. 

 

Ascertain the base number of activities you need to perform so that a becomes arranged, or report that it is unimaginable. 

 

Input 

 

The main line contains one integer t (1≤t≤500) — the number of experiments. 

 

Each experiment comprises of two lines. The main line contains two integers n and x (1≤n≤500, 0≤x≤500) — the number of components in the succession and the underlying worth of x. 

 

The subsequent line contains n integers a1, a2, ..., an (0≤ai≤500). 

 

The amount of upsides of n over all experiments in the input doesn't surpass 500. 

 

Output 

 

For each experiment, print one integer — the base number of activities you need to perform to make an arranged, or −1, in case it is inconceivable.

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Predicate
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole