Array Splitting into two parts <P2SME>
Practice
4.4 (5 votes)
Algorithms
Dynamic programming
Medium
Two dimensional
Problem
56% Success 590 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code

You are given an array of size N. Distribute the elements of the array into two parts such that the \(product\) of the \(sum\) of two parts is maximum.

In other words,

Let \(f(x)\) denote sum of the elements in \(Part 1\).

Let \(g(x)\) denote sum of the elements in \(Part 2\).

You need to maximise \(f(x)*g(x)\)

Input :
First line contains an integer N, denoting number of elements in array.
Next line contains N integers denoting the array elements.

Output :

Maximum value of \(f(x)*g(x)\).

Constraints :

\(1 \le N \le 100\)

\(1 \le A[i] \le 500\)


Note: It is not mandatory to use the code snippet that is provided to you in the editor by default. It is just to make the question more convenient. You can completely remove the default code and submit your solution in the appropriate format.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
11 votes
Tags:
Dynamic Programming2D dynamic programmingAlgorithms
Points:30
3 votes
Tags:
AlgorithmsDynamic ProgrammingMathMatrixMediumTwo dimensional
Points:30
1 votes
Tags:
AlgorithmsDynamic ProgrammingDynamic programmingMathMediumTwo dimensional