luogu#P10705. 孤独(Solitude)
孤独(Solitude)
Background
Problem Description
You are given , and integers (), and integers ().
Now, for a sequence of length , the following rules apply:
-
or .
-
For all (), if and , then is called a peak. In particular, .
You need to find: the maximum number of peaks, and the maximum range when the number of peaks is maximized.
Range: the difference between the maximum value and the minimum value in a sequence.
Updated: and do not participate in the range calculation.
Input Format
The first line contains an integer .
The second line contains integers, representing .
The third line contains integers, representing .
Output Format
Output two lines in total.
The first line contains an integer representing the maximum number of peaks.
The second line contains an integer representing the maximum range when the maximum number of peaks is achieved.
6
9 1 2 4 7 10
8 10 5 1 1 7
3
9
10
6 13 27 31 34 59 64 66 71 95
4 4 10 22 26 28 46 55 62 68
5
91
Hint
Sample Explanation
In Sample 1, one valid sequence is .
Among them, are peaks, and the range is .
Constraints
| Subtask ID | Special Property | Score | |
|---|---|---|---|
Special property : , .
Special property : , $\text{min}(a_i,b_i)\le\text{max}(a_{i-1},b_{i-1})\le\text{max}(a_i,b_i)$.
Special property : , , where is a positive integer.
For of the testdata, , , and it is guaranteed that .
Special reminder: This problem uses bundled subtask testing. You only get the score of a subtask if you pass all test points in that subtask.
Translated by ChatGPT 5