Elevator SOLUTIONS ELEVATR

Elevator SOLUTIONS ELEVATR

Gourmet specialist’s loft comprises of M floors (numbered 1 through M), and a lift is utilized to move between various floors. The lift is associated with a PC which enrolls its development in an arrangement B. At whatever point the lift moves to an alternate floor, the PC adds the new floor number to succession B. Presently, the succession B has N components. 
 
Shockingly, the PC is tainted with an infection which supplanted a few components of B by −1s. Culinary specialist currently needs to recognize what could be the base number of times the lift has altered its course. That is, how frequently the lift was going up then began going down and the other way around. 
 
Help gourmet specialist by responding to his question or establish that the arrangement B is invalid. 
 
Info: 
 
The main line of the info contains a solitary whole number T indicating the quantity of experiments. The portrayal of T experiments follows. 
 
The principal line of each experiment contains two numbers N and M. 
 
The subsequent line contains N space-isolated whole numbers B1,B2,… ,BN. 
 
Yield: 
 
For each experiment, print a solitary line containing one whole number ― the base number of times the lift has altered its course or −1 if the given B succession is invalid. 
 
Requirements 
 
1≤T≤1000 
 
1≤N≤105 
 
2≤M≤105 
 
1≤Bi≤M or Bi=−1 for each legitimate I 
 
whole of N over all experiments doesn’t surpass 106 
 
Subtasks 
 
Subtask #1 (50 focuses): 
 
N≤1,000 
 
the whole of N over all experiments doesn’t surpass 10,000 
 
Subtask #2 (50 focuses): Original limitations 
 
Test Input: 
 
 
4 5 
 
2 3 4 3 
 
4 5 
 
2 – 1 4 3 
 
4 5 
 
1 – 1 – 1 5 
 
5 4 
 
– 1 – 1 3 – 1 – 1 
 
 
– 1 – 1 3 – 1 – 1 
 
Test Output: 
 
 
 
– 1 
 
 
0
 

March Long Challenge 2021 Solutions

April Long Challenge 2021 Solutions

Codechef Long Challenge Solutions

February Long Challenge 2021

1. Frog Sort Solution Codechef

2. Chef and Meetings Solution Codechef

3. Maximise Function Solution Codechef

4. Highest Divisor Solution Codechef

5. Cut the Cake Challenge Solution Codechef

6. Dream and the Multiverse Solution Codechef

7. Cell Shell Solution Codechef

8. Multiple Games Solution Codechef

9. Another Tree with Number Theory Solution Codechef

10. XOR Sums Solution Codechef

11. Prime Game Solution CodeChef

12. Team Name Solution Codechef

January Long Challenge 2021

November Challenge 2020 SOLUTION CodeChef

October Lunchtime 2020 CodeChef SOLUTIONS

RELATED :

Related :

Related :

Leave a Comment