atcoder#ABC304D. [ABC304D] A Piece of Cake
[ABC304D] A Piece of Cake
Score : points
Problem Statement
There is a rectangular cake with some strawberries on the -plane. The cake occupies the rectangular area $\lbrace (x, y) : 0 \leq x \leq W, 0 \leq y \leq H \rbrace$.
There are strawberries on the cake, and the coordinates of the -th strawberry are for . No two strawberries have the same coordinates.
Takahashi will cut the cake into several pieces with a knife, as follows.
- First, cut the cake along different lines parallel to the -axis: lines , , , .
- Next, cut the cake along different lines parallel to the -axis: lines , , , .
As a result, the cake will be divided into rectangular pieces. Takahashi will choose just one of these pieces to eat. Print the minimum and maximum possible numbers of strawberries on the chosen piece.
Here, it is guaranteed that there are no strawberries along the edges of the final pieces. For a more formal description, refer to the constraints below.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the minimum possible number of strawberries and the maximum possible number on the chosen piece in the following format, separated by a space.
7 6
5
6 1
3 1
4 2
1 5
6 2
2
2 5
2
3 4
0 2
There are nine pieces in total: six with zero strawberries, one with one strawberry, and two with two strawberries. Therefore, when choosing just one of these pieces to eat, the minimum possible number of strawberries on the chosen piece is , and the maximum possible number is .
4 4
4
1 1
3 1
3 3
1 3
1
2
1
2
1 1
Each piece has one strawberry on it.