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

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

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
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