To divide the elements into K segments such that the sum of minimum element of each segment is maximum

Given an array of N elements divide the elements into K segments such that the sum of minimum element of each segment is maximum Sample Input : N=4 K=2

1 2 5 3

Sample Output : 4

[1,2,5]+[3]
You should know by now that you can't just dump your assignment without posting some attempt at solving the problem yourself.

Just for reference, in case of "delete and run away"

Given an array of N elements divide the elements into K segments such that the sum of minimum element of each segment is maximum Sample Input : N=4 K=2

1 2 5 3

Sample Output : 4

[1,2,5]+[3]
Last edited on
Note that the sample has a second solution:
[1,2]+[5,3]

The task is about math and algorithms. Those you have to figure out yourself.

If your C++ implementation of your algorithm has issues, then we can help.
Topic archived. No new replies allowed.