#K80722. Non-Overlapping Flower Beds

    ID: 35594 Type: Default 1000ms 256MiB

Non-Overlapping Flower Beds

Non-Overlapping Flower Beds

In this problem, you are given a set of flower beds defined by the coordinates of their bottom‐left and top‐right corners. Two flower beds are considered overlapping if their horizontal projections intersect. You need to choose a maximum subset of flower beds such that no two selected flower beds overlap.

Formally, each flower bed is described by four integers (x_1, y_1, x_2, y_2). Two flower beds (A) and (B) are considered non overlapping if the condition (x_{1}^{(B)} \geq x_{2}^{(A)}) holds (after a proper ordering). Your task is to compute the maximum number of non overlapping flower beds you can select from the given list.

inputFormat

The input is read from standard input. The first line contains an integer (n) representing the number of flower beds. Each of the following (n) lines contains four space-separated integers (x_1, y_1, x_2, y_2) describing a flower bed.

outputFormat

Output a single integer representing the maximum number of non overlapping flower beds that can be chosen.## sample

3
1 1 3 3
2 2 4 4
5 5 6 6
2