Amazon OA Question | 2021
Anonymous User
1561

You are given an array that contains marks of N students in a class. Now the each student i has the choice to give exam in a group of atmost K continous students. In that group each student scores the same marks as the topper of the group. Find the total maximum score of all the students that can be acheived.

Input -

N = 5
MARKS = 8 2 7 6 1
K = 2

Output -

35

Explanation -

The students can form groups of size atmost 2 in the following way
8, 8, 7, 6, 6 which maximises our answer as 8 and 2 form a group and 6 and 1 form a group and 7 alone forms another group.

Initially I thought of DP but wasen't able to come up with a solution. Any help with explanation will be appreciated...

Comments (2)