SP2321 SEGMENTS - Segments
Description
There are N horizontal line segments in the plane. The ith segment has some height h $ _{i} $ (which may be negative) and runs from x = a $ _{i} $ to x = b $ _{i} $ (a $ _{i} $ < b $ _{i} $ ). Segments do not contain their endpoints. You must draw a set of vertical lines (note _lines_ and not _line segments_) so that every given horizontal segment is intersected at least once and at most R times by vertical lines in such a way that R is minimized.
Input Format
The first line of the input is N (1 ≤ N ≤ 400), the number of horizontal line segments. N lines then follow, where the ith line is "a $ _{i} $ b $ _{i} $ h $ _{i} $ ". Each of a $ _{i} $ ,b $ _{i} $ ,h $ _{i} $ are 32-bit signed integers. Horizontal segments may overlap.
Output Format
Your output should consist of a single integer, the smallest value of R that is achievable, followed by a newline.