#P2418. yyy loves OI IV
yyy loves OI IV
Description
There are other students in the school besides them, and each student idolizes one of them. Now the teacher needs to assign them to dorm rooms. However, here is the issue:
For any dorm room, either everyone in it idolizes the same person, or the absolute difference between the numbers of students who idolize yyy and c01 in that room is at most . Otherwise, they will start a fight.
To make things easier, the teacher makes the students stand in a line. Only people who stand consecutively can be placed into the same dorm room.
Assume each dorm room can hold arbitrarily many people. What is the minimum number of dorm rooms needed?
Input Format
The first line contains two positive integers and .
Lines each contain one integer, or . The number on line indicates, from left to right, the -th person’s choice: means yyy, and means c01.
Output Format
One line with a single integer, the minimum number of dorm rooms needed.
5 1
1
1
2
2
1
1
Hint
| Test point ID | Range of | Range of |
|---|---|---|
Translated by ChatGPT 5
京公网安备 11011102002149号