All submissions for this problem are available.
Ravi is very fond of playing cricket. As he has a tournament match this weekend, he has practiced very well. His mother is helping him tabulate his growth by keeping all the records of improvement in his practice day by day. Now the day has come and Ravi is going to perform today. As his mother wants to calculate the success rate of her son, she decides to calculate the maximum fluctuation in her son’s performance during the practice. If A[i] is the score he made on the ith day and he has practiced for N days, then
Fluctuation = max (A[j]-A[i]) for all i,j satisfying 1 ≤ i < j ≤ N.
Now she wants your help to efficiently calculate it.
NOTE: fluctuation can be negative.
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. First line of each test case has integer N denoting the number of days Ravi did practice. Next line contains N space separated integers denoting the array A.
For each test case, output only line containing the maximum fluctuation.
- 1 ≤ T ≤ 10000
- 2 ≤ N ≤ 1000
- 0 ≤ A[i] ≤ 10^9
Input: 1 5 15 3 13 2 18 Output: 16
A - A will be the maximum fluctuation.
|Time Limit:||6 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