Be a comrade
Christy is assistant professor at a part time college. One day she has to distribute a responsibility of an event to her students at the college. She is biased towards her students and may have distributed the responsibility unequally. One of the Professors who believes in Marxian principles gets to know this and orders Christy to make sure everyone gets equal responsibility.
But to make things difficult for her, she is ordered to equalize the responsibility for every student in the following manner
For every operation, she can choose one of her students and can do one of the three things.
(i) She can give one responsibility to every student other than chosen one.
(ii) She can give two responsibility to every student other than chosen one.
(iii) She can give five responsibility to every student other than chosen one.
Calculate minimum number of such operations needed to ensure that every student has the same number of responsibility.
First line contains an integer T denoting the number of testcases.
T testcases follow.Each testcase has 2 lines.
First line of each testcase contains an integer N denoting the number of students.
Second line contains N space separated integers denoting the current number of responsibility each student has.
T lines, each containing the minimum number of operations needed to make sure all students have the same number of responsibility.
Number of initial responsibility each student has < 1000
2 2 3 7
|Time Limit:||5 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, 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