_Chaitanya1999's blog

By _Chaitanya1999, history, 10 months ago, In English

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. 

Read more »

  • Vote: I like it
  • -5
  • Vote: I do not like it