#C9910. Maximum Collage Dimensions
Maximum Collage Dimensions
Maximum Collage Dimensions
You are given a collection of photos along with the year each photo was taken. The goal is to determine the maximum dimensions of a photo collage.
The collage is arranged such that:
- The number of rows is equal to the maximum number of photos taken in the same year.
- The number of columns is equal to the total number of distinct years in which the photos were taken.
Mathematically, if \(f(y)\) denotes the number of photos taken in year \(y\), and \(Y\) is the set of all distinct years, then the answer is:
\[ \text{maxRows} = \max_{y \in Y} f(y), \quad \text{maxColumns} = |Y| \]Your task is to compute these two numbers given the input format described below.
inputFormat
The input is taken from stdin
and is structured as follows:
- The first line contains an integer \(n\), representing the number of photos.
- The next \(n\) lines each contain two integers separated by a space. The first integer represents a unique photo ID (which is not used in calculations), and the second integer represents the year the photo was taken.
For example:
6 1 2005 2 2005 3 2006 4 2007 5 2006 6 2005
outputFormat
Output to stdout
two integers separated by a space. The first integer is the maximum number of photos taken in any single year (i.e. number of rows), and the second integer is the number of distinct years (i.e. number of columns).
For the above input, the output should be:
3 3## sample
6
1 2005
2 2005
3 2006
4 2007
5 2006
6 2005
3 3