flΓ’neur

Problem - 1554A - Codeforces

codeforces.com Β· saved by 1 readers

You are given n 𝑛 integers a 1 , a 2 ,…, a n π‘Ž 1 , π‘Ž 2 , … , π‘Ž 𝑛 . Find the maximum value of max( a l , a l+1 ,…, a r )β‹…min( a l , a l+1 ,…, a r ) π‘š π‘Ž π‘₯ ( π‘Ž 𝑙 , π‘Ž 𝑙 + 1 , … , π‘Ž π‘Ÿ ) β‹… π‘š 𝑖 𝑛 ( π‘Ž 𝑙 , π‘Ž 𝑙 + 1 , … , π‘Ž π‘Ÿ ) over all pairs (l,r) ( 𝑙 , π‘Ÿ ) of integers for which 1≀l<r≀n 1 ≀ 𝑙 < π‘Ÿ ≀ 𝑛 . The first line contains a single integer t 𝑑 ( 1≀t≀10000 1 ≀ 𝑑 ≀ 10 000 ) Β β€” the number of test cases. The first line of each test case contains a single integer n 𝑛 ( 2≀n≀ 10 5 2 ≀ 𝑛 ≀ 10 5 ). The second line of each test case contains n 𝑛 integers a 1 , a 2 ,…, a n π‘Ž 1 , π‘Ž 2 , … , π‘Ž 𝑛 ( 1≀ a i ≀ 10 6 1 ≀ π‘Ž 𝑖 ≀ 10 6 ). It is guaranteed that the sum of n 𝑛 over all test cases doesn't exceed 3β‹… 10 5 3 β‹… 10 5 . For each test case, print a single integer Β β€” the maximum possible value of the product from the statement. Let f(l,r)=max( a l , a l+1 ,…, a r )β‹…min( a l , a l+1 ,…, a r ) 𝑓 ( 𝑙 , π‘Ÿ ) = π‘š π‘Ž π‘₯ ( π‘Ž 𝑙 , π‘Ž 𝑙 + 1 , … , π‘Ž π‘Ÿ )

saved by