#K9476. Store Plates
Store Plates
Store Plates
You are given (n) rectangular plates. For each plate, you are provided two positive integers describing its dimensions. You are allowed to rotate each plate by 90° so that the smaller dimension is placed along the (y)-axis and the larger along the (x)-axis. Your task is to compute the minimal required maximum (x)-coordinate (width) and (y)-coordinate (height) needed to store all the plates side by side.
In other words, for each plate with dimensions (a) and (b), let (w = \max(a, b)) and (h = \min(a, b)). The answer is given by (X = \max(w_1, w_2, \ldots, w_n)) and (Y = \max(h_1, h_2, \ldots, h_n)).
inputFormat
The first line contains an integer (n) ((1 \le n \le 10^5)), the number of plates. Each of the following (n) lines contains two space-separated positive integers representing the dimensions of a plate.
outputFormat
Output two integers separated by a space: the minimal maximum (x)-coordinate and the minimal maximum (y)-coordinate required to store the plates.## sample
3
2 3
3 2
1 4
4 2