#P10878. [JRKSJ R9] 在相思树下 III
[JRKSJ R9] 在相思树下 III
Background
I know.
No matter how much I am obsessed with him, he cannot be mine alone.
Just treat it as God loving the world, distant and gentle.
Holding hands is not necessary.
Across tens of millions of light-years, the universe offers a kiss.
It can still be felt clearly.
No need.
To force it.
To fit yourself into that made-up role.
Problem Description
You are given a sequence of length . You need to perform two types of operations on it for a total of times.
For a sequence of length , performing one operation will turn it into a sequence of length :
- In operation 1, .
- In operation 2, .
Given an integer , you can perform operation 1 at most times. After performing operations, the length of sequence becomes . You may arrange the order of operations arbitrarily. Find the maximum possible value of the final remaining number .
Input Format
The first line contains two integers .
The second line contains integers , representing the initial sequence.
Output Format
Output one integer, representing the maximum possible value of the final remaining number.
4 2
1 2 3 3
3
Hint
Sample Explanation
One possible order of operations is:
- Perform operation 1 once, and the sequence becomes .
- Perform operation 2 once, and the sequence becomes .
- Perform operation 1 once, and the sequence becomes .
Obviously, the final remaining number cannot be greater than .
Constraints
This problem uses bundled testdata.
| Special property | Score | ||
|---|---|---|---|
Special property: it is guaranteed that .
For all data, it is guaranteed that , and .
Translated by ChatGPT 5