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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education