Array Splitting into two parts <P2SME>

4.4

5 votes
Algorithms, Dynamic Programming, Medium, Two dimensional
Problem

You are given an array of size N. Distribute the elements of the array into two parts such that the of the of two parts is maximum.

In other words,

Let denote sum of the elements in .

Let denote sum of the elements in .

You need to maximise

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 .

Constraints :


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.

Sample Input
4
2 3 5 6
Sample Output
64
Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

Maximum is possible when part 1 contains and part 2 contains

Editor Image

?