B. Maximum Product SOLUTION CODEFORCES

Maximum Product SOLUTION

You are given a variety of numbers a1,a2,… ,an. Locate the most extreme conceivable estimation of aiajakalat among every one of the five lists (i,j,k,l,t) (i<j<k<l<t). 
 
Information 
 
The information comprises of various experiments. The main line contains a number t (1≤t≤2⋅104) — the quantity of experiments. The depiction of the experiments follows. 
 
The principal line of each experiment contains a solitary whole number n (5≤n≤105) — the size of the cluster. 
 
The second line of each experiment contains n whole numbers a1,a2,… ,a (−3×103≤ai≤3×103) — given exhibit. 
 
It’s ensured that the aggregate of n over all experiments doesn’t surpass 2⋅105. 
 
Yield 
 
For each experiment, print one number — the response to the issue. 
 
Model 
 
inputCopy 
 
 
 
– 1 – 2 – 3 – 4 – 5 
 
 
– 1 – 2 – 3 1 2 – 1 
 
 
– 1 0 – 1 – 1 
 
 
– 9 – 7 – 5 – 3 – 2 1 
 
outputCopy 
 
– 120 
 
12 
 
 
945 
 
Note 
 
In the main experiment, picking a1,a2,a3,a4,a5 is a most ideal decision: (−1)⋅2⋅(−3)⋅(−4)⋅(−5)=−120. 
 
In the subsequent experiment, picking a1,a2,a3,a5,a6 is a most ideal decision: (−1)⋅(−2)⋅(−3)⋅2⋅(−1)=12. 
 
In the third experiment, picking a1,a2,a3,a4,a5 is a most ideal decision: (−1)⋅0⋅0⋅0⋅(−1)=0. 
 
In the fourth experiment, picking a1,a2,a3,a4,a6 is a most ideal decision: (−9)⋅(−7)⋅(−5)⋅(−3)⋅1=945.
 

Leave a Comment

close
error: Content is protected !!