NITT8  Dating Rishi
Dating Rishi
Its been Monday and Rishi Dudeis planning to select a girl to date for this week. So all N girls are standing in a line from 1 to N so that Rishi will select one of them. The girls are standing in a straight line but randomly. They know they cannot predict what Rishi The Great likes, He may like hot, smart, tall, short, witty, white, black or anything. But wait, Rishi, the Coolest Dude plans to date two girls this week !!! How lucky they are ????. But he wants to select two girls whose friendship quotient is maximum so that they wont fight too much over Rishi during the date. He is shy too !. Friendship quotient is defined as the product of absolute difference between the position of the two girls and the minimum height of the two girls.
Can you help Rishi to find the maximum friendship quotient ?
Input Specification
The first line of input file contains T which denotes number of testcases.
2*T lines follows.
First line of each test case contains an integer N.
Second line of each test case contains N space separated integers denoting the height of each girl.
Output Specification
The output must contain T lines each line corresponding to a testcase.
Constraints
T <= 20
N <= 100000
Height[i] <= 10^9
Sample Input:
2 4 3 2 1 3 5 4 2 3 1 4
Sample Output:
9 16
hide comments
Agam Gupta:
20140530 12:46:21
gud one !! 

Shanks:
20140519 15:54:53
use long long for this.. 

suryadev:
20140214 17:21:36
nice prob! 

ABHISHEK004:
20140114 22:35:03
nice ques.. done in o(n) :) 

OTAKU:
20140114 19:56:53
Good qn learn a lot but my logic is in O(n)...feeling gud...


anurag garg:
20131217 11:40:17
good ques....AC at one go 

fitcat:
20130719 09:04:40
Nice one :) 

aqfaridi:
20150104 23:29:05
nice prob.. 

BLANKRK:
20130625 18:37:22
AC :D . . .


super human:
20130613 22:19:14
enjoyed solving this one...!!! 
Added by:  jack(chakradarraju) 
Date:  20120930 
Time limit:  1s2s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Radhakrishnan 