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

Jul 14, 2019 at 7:08am
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]
Jul 14, 2019 at 7:39am
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 Jul 14, 2019 at 7:40am
Jul 14, 2019 at 7:45am
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.