Couple the Time
All submissions for this problem are available.
Aditi needs to design an operating system in competition with the trending ones. She is more concerned about process management than any other function of the OS. She has already designed algorithms but needs to check how efficient she is. You, as her test designer, are to design a benchmark application in order to determine efficiency for a particular set of processes.
You are given an array of size N indicating the burst time of the processes. Any two processes with burst times A and B will combine as A+B mod 100 (can’t help the calculation says it), and the time consumed to combine these is (A*B) (COUPLING TIME!). The Benchmark application is concerned in minimizing the COUPLING TIME. Help Aditi to design the Benchmark application.
Input:First line will contain an integer T denoting the number of test cases Each T lines contains an integer N number of processes Next line contains burst time of N processes
Output:For each test case output the minimum amount of COUPLING TIME.
- 1 ≤ T,N ≤ 100
- 1 ≤ A[i] ≤ 100
40 60 20
For the first test case, the answer will be 18*19 = 342.
In the second test case, there are two possibilities:
first couple 40 and 60 (coupling time: 2400), getting 0, then couple 0 and 20 (coupling time: 0); total coupling time is 2400.
first couple 60 and 20 (coupling time: 1200), getting 80, then couple 40 and 80 (coupling time: 3200); total coupling time is 4400. The first scenario is a much better way to proceed.
|Time Limit:||1 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