Question: C++ using data structures, please ensure the input output is exactly the same as the sample Boring job One day, Rick got a sequence of

C++ using data structures, please ensure the input output is exactly the same as the sample  C++ using data structures, please ensure the input output is exactly

Boring job One day, Rick got a sequence of N magic numbers. In order to find the latent code in the sequence, he decides to do the following operations with a magic parameter K: Step (1) Take out the first K numbers from current sequence S into a temporary sequence ni, n2, ny and pick the largest element Vmax out of these K numbers then subtract 1 from the remaining K-1 elements. If there exist more than one largest element, choose the one with smaller index in temporary sequence. Step (2) Print the index (count from 1) of Vmax in the initial sequence, append the rest K-1 elements (with subtraction done) in temporary sequence back to the end of S Repeat (112) until S become empty. if the size of S is smaller than K, in step (1) just take out all the elements Since Rick is too smart to be interested in doing this on his own, he asked his grandchild Morty to do this jgb for him. Howeve, Morty is just not clever enough to do this job Can you use your programming skill to help poor Morty? Input The first line of input is an integer T (1 T 10) indicating the number of test cases Each test case will follow the format shown below: The first line: Two integers N and K showing the length of sequence and magic parameter in this test case. The second line: N integers ma, mmy showing magic numbers in the sequence. (1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!