Bat In Cage
All submissions for this problem are available.
Batman is trapped by Lex Luthor and given a puzzle to solve in captivity. Since Frank Miller is not here to help him, he asks you to solve the problem for him. The problem Luthor stated was "Given an array of integers, find a pair of integers x,y such that the sum of the function
over all the elements in the array is as small as possible."
First line contains number of test cases
Second line contains the size of the array n, and in the next line, n integers denoting the array.
The sum of the minimized function with the ideal pair x,y.
- Summation of n over all test cases <= 106
Input: 1 5 1 2 3 4 5 Output: 3
Example case 1 : 2 and 4 are the ideal pair.
|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