#P13009. 【MX-X13-T4】「KDOI-12」好胜是人的本能,功利是社会的本性。
【MX-X13-T4】「KDOI-12」好胜是人的本能,功利是社会的本性。
Description
Given a sequence of positive integers of length and a positive integer satisfying , you can perform any number of operations (including zero) on the sequence. In each operation, you may select an interval and for all , set .
Your task is to determine:
- The maximum possible value of achievable through these operations.
- The minimum number of operations required to achieve this maximum sum.
Input Format
This problem contains multiple test cases.
- The first line contains a positive integer , the number of test cases.
- For each test case:
- The first line contains two positive integers and .
- The second line contains positive integers .
Output Format
For each test case, output two non-negative integers:
- The maximum possible sum .
- The minimum number of operations required to achieve this sum.
3
2 5
1 2
5 10
1 5 2 4 3
10 10
1 4 2 5 1 6 2 7 1 10
7 1
28 3
80 5
Hint
Sample Explanation
For the second test case in the sample input, selecting the following 3 intervals achieves the maximum sum of :
It can be proven that this is one of the optimal solutions.
Data Range
This problem uses bundled testing.
| Subtask | Points | Special Properties | ||
|---|---|---|---|---|
| None | ||||
| A | ||||
| B | ||||
| None |
- Special Property A: .
- Special Property B: divides (i.e., ).
For all test cases:
- ,
- ,
- ,
- .
Translated by DeepSeek V3.
京公网安备 11011102002149号