#P7804. [JOI Open 2021] 决算报告 / Financial Report
[JOI Open 2021] 决算报告 / Financial Report
Description
There is a sequence of length . Define the value of the function as the number of indices that satisfy:
When , we assume that the inequality above always holds.
Given an integer , find a sequence that satisfies:
- ;
- ;
- ;
- If , then ;
- The value of is maximized.
Output the maximum value of the function .
Input Format
The first line contains two integers , with the meaning as described in the statement.
The second line contains integers , representing the given sequence.
Output Format
Output one integer on a single line, representing the maximum value of the function .
7 1
100 600 600 200 300 500 500
3
6 6
100 500 200 400 600 300
4
11 2
1 4 4 2 2 4 9 5 7 0 3
4
Hint
Sample 1 Explanation
There are possible cases in total:
- , ;
- , ;
- , ;
- , ;
- , ;
- , ;
- , .
The maximum value is .
Sample 2 Explanation
The optimal . The corresponding , and the value of is .
Sample 3 Explanation
There are multiple optimal ways. One of them is . The corresponding , and the value of is .
Constraints
This problem uses bundled testdata.
- Subtask 1 (14 pts): ;
- Subtask 2 (14 pts): ;
- Subtask 3 (20 pts): ;
- Subtask 4 (12 pts): ;
- Subtask 5 (5 pts): ;
- Subtask 6 (35 pts): no special restrictions.
For of the testdata:
- ;
- ;
- .
Notes
Translated from JOI 2020 / 2021 Open Contest B Financial Report.
Translated by ChatGPT 5
京公网安备 11011102002149号