An Interesting Problem...Help Needed!

Revision en2, by _Chaitanya1999, 2021-01-21 09:03:24

If you want to directly access the problem you can click here


Problem Statement You are given array a of n integers. You need to split the array into 2 arrays (one of which may be empty) such that sum of product of these 2 arrays is maximum. Formally, you need to find l such that sum of a1⋅a2⋅⋯⋅al and al+1⋅al+2⋅⋯⋅an is maximum over all valid choices for l. Note that an empty array has a product of 0.

Output Print the maximum sum of product of the arrays mod 1e9+7.

Constraints 1≤n≤1e5 , 1≤|ai|≤1e9
I tried to solve this problem by pre-calculating prefix product and suffix product modulo M(1e9+7) and taking the maximum among every i (1<=i<=n).But still its showing me WA for large inputs of a[i]. Can anyone suggest me where am I making a mistake ?
Thanks in Advance. 
Tags #dp with modulus

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English _Chaitanya1999 2021-01-21 09:03:24 60 Tiny change: 'oblem/C)\n~~~~~\n\' -> 'oblem/C)\n\n~~~~~\n\' (published)
en1 English _Chaitanya1999 2021-01-21 08:58:52 1007 Initial revision (saved to drafts)