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
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
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.
Step by step
Solved in 4 steps with 1 images