Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 399 Weeks Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 15 Sep 2017 My Price 10.00

Blu-Ray discs

A DVD Store has just put up "Interstellar" DVD/Blu-Ray discs on their shelf for sale. N people are waiting outside the store in a queue to grab their copy.They are given tickets which has a number x printed on it. The number denotes the Serial Number of the DVD they should take and proceed to the checkout. The number printed on the tickets are in no particular order.
The store has the checkout section at the beginning of the shelf.

 

There are N DVD's on the shelf at the store.Initially the serial number of the DVD's are in the order from 1 to N.The DVD with serial number x is at a distance of x units from the checkout section of the DVD store.When the store opens first person enters, moves to the DVD which has the serial number equal to his/her ticket number, takes it from the shelf and moves to the checkout section.After taking the DVD, all the DVD's which has serial numbers greater than the currently taken DVD and still present in the shelf, move 1 unit up the shelf to close the gap created by the removed DVD.All N people claim their DVD's from the store.

 

Your task is to print the distance traveled by all N people to get his/her DVD copy. (Do not include the return distance to the checkout section).

 

Input

 

  • The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
  • The first line of each test case contains a single integer N denoting the number of number of DVD's and the number of people waiting in the queue. The second line contains N space-separated integers A1, A2, ..., AN denoting the number printed on the tickets of the people waiting outside.

 

 

Output

 

  • For each test case, output N space separated integers, where each number denotes the distance each person has to travel to get his/her DVD(Do not include the return distance to checkout).

 

 

Constraints

 

  • 1 = T = 5
  • 1 = N = 100000
  • 1 = Ai = N

 

 

 

Example

Input: 1 5 2 3 1 4 5 Output: 2 2 1 1 1

Answers

(5)
Status NEW Posted 15 Sep 2017 11:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)
Relevent Questions