The Book of Love
All submissions for this problem are available.
Mr. Agarwal got a gift from his beloved on this valentine. She gave him a book titled "The Book of Love". The book contains several chapters and each chapter contains some pages.
Mr. Agarwal have to read this book in a given number of days. Once he starts reading a chapter, he always completes it. He is a good mathematician so he decide to read the book in a unique way. He calculates average number of pages to be read in one day and read chapters in such fashion that he deviates minimum from this average.
Mr. Agarwal wants you to calculate his total deviaton from the aveage.
- "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 two integers D and C denoting numbers of days and chapters respectively. The second line contains C space-separated integers P1, P2, ..., PC denoting the number of pages in each chapter.".
- For each test case, output a single line containing the total deviation from the average number of pages.
- 1 ≤ T ≤ 10
- 1 ≤ D ≤ 100
- 1 ≤ C ≤ 1000
- 1 ≤ Pi ≤ 100
Input: 2 4 6 3 5 7 9 5 3 2 3 2 1 1 Output: 2 0.
Example case 1. ...
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.