#C5519. Maximizing Product Ratings Under Skipping Constraint

    ID: 49177 Type: Default 1000ms 256MiB

Maximizing Product Ratings Under Skipping Constraint

Maximizing Product Ratings Under Skipping Constraint

You are given a sequence of \( n \) products with their ratings. Your task is to choose exactly \( k \) products to display. However, to ensure some continuity in the presentation, you are not allowed to skip more than \( m \) consecutive products between any two selections. Formally, if the positions of two consecutively selected products are \( i \) and \( j \) (with \( i < j \)), the gap between them, \( j-i-1 \), must satisfy:

\( j - i - 1 \le m \).

Your goal is to compute the maximum total rating that can be obtained by selecting \( k \) products following the above rule.

inputFormat

The first line of input contains three integers: \( n \) (the total number of products), \( m \) (the maximum number of consecutive products that can be skipped), and \( k \) (the number of products to select).

The second line contains \( n \) integers, where each integer represents the rating of a product.

outputFormat

Output a single integer - the maximum total rating achievable by selecting exactly \( k \) products under the given constraint.

## sample
7 2 3
1 2 3 4 5 6 7
18

</p>