Question 1: Curriculum Conflicts
Little A has taken n courses, and the i-th course is taken from the ai-th day to the bi-th day.
Define the degree of conflict between two courses as: There are days when both courses are taken.
For example, when a1=1, b1=3, a2=2, b2=4, the degree of conflict between these two courses is 2.
Now what you need to ask is the degree of conflict between the two courses with the greatest degree of conflict among the n courses.
Time limit: 1000
Memory limit: 65536
input
In the first line, a positive integer n represents the number of courses. Next n lines, each line has two positive integers ai, bi. 2 ≤ n ≤ 1000, 1 ≤ ai ≤ bi ≤ 1000.
Output
Output an integer representing the maximum degree of conflict.
Sample input
3
1 3
2 4
5 5
Sample output
2
The title requires finding out the degree of conflict between the two courses with the greatest degree of conflict among n courses. The level of conflict indicates that there are days when both courses are taught.
Problem-solving ideas:
(1) Create an array conflict with a length of 1001, which is used to record how many courses are to be taken each day.
(2) Traverse each course, and for the time range [a, b] of each course, add 1 to the values of conflict[a]~conflict[b], indicating that there is a course to be taken in these days.
(3) traverse the conflict array,