Culinary specialist Monocarp has recently put n dishes into a broiler. He realizes that the I-th dish has its ideal cooking time equivalent to ti minutes.    At any certain integer minute T Monocarp can put close to one dish out of the broiler. On the off chance that the I-th dish is put out at some moment T, its undesirable worth is |T−ti| — the outright contrast

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter11: Nonlinear Programming
Section: Chapter Questions
Problem 13RP
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.

Culinary specialist Monocarp has recently put n dishes into a broiler. He realizes that the I-th dish has its ideal cooking time equivalent to ti minutes. 

 

At any certain integer minute T Monocarp can put close to one dish out of the broiler. On the off chance that the I-th dish is put out at some moment T, its undesirable worth is |T−ti| — the outright contrast among T and ti. When the dish is out of the stove, it can't return in. 

 

Monocarp should put every one of the dishes out of the stove. What is the base all out unsavory worth Monocarp can acquire? 

 

Input 

 

The principal line contains a solitary integer q (1≤q≤200) — the number of testcases. 

 

Then, at that point, q testcases follow. 

 

The principal line of the testcase contains a solitary integer n (1≤n≤200) — the number of dishes in the broiler. 

 

The second line of the testcase contains n integers t1,t2,… ,tn (1≤ti≤n) — the ideal cooking time for each dish. 

 

The amount of n over all q testcases doesn't surpass 200. 

 

Output 

 

Print a solitary integer for each testcase — the base complete terrible worth Monocarp can get when he puts out every one of the dishes out of the broiler. Recollect that Monocarp can just put the dishes out at positive integer minutes and close to one dish all of a sudden.

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
Decision Tree
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole