#P7169. [eJOI 2020] Exam (Day1)
[eJOI 2020] Exam (Day1)
Problem Description
Given a sequence of length , you can perform the following operation any number of times:
- Choose an interval of length at least , such that all numbers in this interval are equal to the maximum value in this interval.
You need to use these operations to make . Find the maximum number of positions that can be made to satisfy the requirement.
Input Format
The first line contains an integer , representing the length of the sequence.
The second line contains integers, representing the sequence .
The third line contains integers, representing the sequence .
Output Format
Output one integer on a single line, representing the answer.
3
1 2 3
2 2 2
2
4
10 1 9 1
10 9 10 9
3
Hint
Sample 1 Explanation
You can choose to perform the operation on the interval . At most numbers can satisfy the requirement.
Sample 2 Explanation
Either or can satisfy the requirement, but they cannot satisfy the requirement at the same time.
Constraints
This problem uses bundled testdata.
- Subtask 1 (14 pts): .
- Subtask 2 (12 pts): , all are equal.
- Subtask 3 (13 pts): , is a strictly increasing sequence.
- Subtask 4 (23 pts): , all are pairwise distinct.
- Subtask 5 (16 pts): .
- Subtask 6 (22 pts): .
For of the testdata:
- .
- .
- .
Note
Translated from eJOI 2020 Day1 C Exam。
Translated by ChatGPT 5