#K57117. Maximize Simultaneous Pet Tricks
Maximize Simultaneous Pet Tricks
Maximize Simultaneous Pet Tricks
In this problem, you are given a lineup of pets, each occupying a distinct position. Two pets cannot perform their tricks simultaneously if they are at adjacent positions because of safety concerns.
Your goal is to choose as many pets as possible to perform their tricks at the same time, ensuring that no two chosen pets are adjacent. Mathematically, if there are \( N \) pets, the maximum number of pets that can perform tricks simultaneously is given by \( \lceil N/2 \rceil \).
Note: Although a list of pet positions is provided, the positions are in order and do not affect the answer since the conflict is only between consecutive pets.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains an integer \( N \), representing the total number of pets.
- The second line contains \( N \) space-separated integers denoting the positions of the pets.
outputFormat
Output a single integer to stdout representing the maximum number of pets that can perform their tricks simultaneously with no two adjacent pets selected.
## sample6
0 1 2 3 4 5
3
</p>