PE Class
InterviewTime limit1sMemory limit1024 MB
Students are sorted by height within each sex group, boys first, and the task is to find the largest height gap between neighbors in the row.
- Level
Easy2 of 10
- Topics
- Sorting, Implementation
- Solved
- No attempts yet
Problem
During PE class, the coach Andrey Sergeevich lines up the students in a single row. The boys stand first, followed by the girls. The boys are arranged in descending order of height, and the girls are too. So the shortest boy is directly followed by the tallest girl.
Andrey Sergeevich wants to know the largest height difference between two students standing next to each other. Write a program that answers this question.
Input
The first line contains an integer , the number of students in the class (). Each of the next lines contains two integers and , the sex and height in centimeters of the -th student (). means the -th student is a boy, and means the -th student is a girl.
Output
Print one integer, the largest height difference between two students standing next to each other after they line up for PE class.