Sequence and Queries 33
Time limit5sMemory limit512 MB
Given an array and range queries (l, r, k), find the maximum total sum of k non-overlapping non-empty subarrays inside A[l..r].
- Level
Hard8 of 10
- Topics
- Dynamic programming, Segment tree, Divide and conquer
- Solved
- No attempts yet
Problem
Given a sequence of length , write a program that processes the following query.
l r k: For the subarray , choose subarrays from it, and print the maximum possible sum of the elements of the chosen subarrays. Each chosen subarray must be non-empty, and the chosen subarrays must not overlap.
Input
The first line contains the size of the sequence and the number of queries ().
The second line contains ().
Each of the next lines contains one query (, ).
Output
For each query, print the result on its own line.