#P2389. 电脑班的裁员

    ID: 1380 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划,dp线性结构洛谷原创

电脑班的裁员

Description

ZZY has a unique downsizing method: each student has an exam score aia_i (1000ai1000-1000 \le a_i \le 1000). Among nn students (n500n \le 500), choose no more than kk (knk \le n) contiguous segments of students to keep, and dismiss the unselected students, so that the sum of the remaining students’ scores is maximized. Note that wrong answers deduct points [don’t ask me why], so scores may be negative.

Input Format

The first line contains n,kn, k. The second line contains the scores of students 11 to nn.

Output Format

A single number ss, the maximum sum of scores.

5 3
1 -1 1 -1 1
3

Hint

2014 Peng Kunzhi: "The statement is so short — looks trivial at first glance."

Translated by ChatGPT 5