#P6821. [PA 2012] Tanie linie

    ID: 7632 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>2012O2优化PA(波兰)

[PA 2012] Tanie linie

Background

PA 2012 R5.

Problem Description

Given a sequence containing nn numbers, find the maximum possible sum of at most kk non-overlapping subarrays.

Input Format

The first line contains two positive integers n,kn, k.

The next line contains nn integers, which form the sequence.

Output Format

Output one integer, the answer.

5 2
7 -3 4 -9 5
13

Hint

For 100%100\% of the testdata, 1kn1061 \le k \le n \le 10^6. All numbers in the sequence are within [109,109][-10^9, 10^9].

Translated by ChatGPT 5