#P7503. 「HMOI R1」文化课
「HMOI R1」文化课
Description
There are people taking an academic proficiency exam. Since they pretend that they have retired, the afternoon CPS0202 has nothing to do with them.
Currently, person has a score . To pass, they need to get at least points. To avoid being suspected by the teacher, their score cannot exceed .
You may organize several cheating sessions. These sessions happen simultaneously, so no one can participate in two or more sessions at the same time. Each cheating session is carried out on a consecutive segment of examinees, and all their scores become the highest score among them.
Find the maximum number of people who can pass and still not be suspected.
Input Format
The first line contains an integer , meaning there are people.
The second line contains integers separated by spaces. The -th number represents the initial score of person .
The next lines each contain two integers. On the -th line are and , with meanings as described above.
Output Format
One line with one integer, representing the maximum number of people who can pass and still not be suspected by the teacher.
6
1 1 4 5 1 4
1 1
4 5
1 4
1 5
1 1
4 4
6
Hint
Organizing one cheating session on can make everyone satisfy the conditions.
This problem uses bundled testdata.
- Subtask 1 ( points): .
- Subtask 2 ( points): .
- Subtask 3 ( points): .
- Subtask 4 ( points): .
- Subtask 5 ( points): .
- Subtask 6 ( points): no special properties.
For of the data, , , .
- Idea: FZzzz.
- Solution: FZzzz.
- Code: FZzzz.
- Data: FZzzz.
Translated by ChatGPT 5
京公网安备 11011102002149号