Algorithm

A. Towers
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Little Vasya has received a young builder’s kit. The kit consists of several wooden bars, the lengths of all of them are known. The bars can be put one on the top of the other if their lengths are the same.

Vasya wants to construct the minimal number of towers from the bars. Help Vasya to use the bars in the best way possible.

Input

The first line contains an integer N (1 ≤ N ≤ 1000) — the number of bars at Vasya’s disposal. The second line contains N space-separated integers li — the lengths of the bars. All the lengths are natural numbers not exceeding 1000.

Output

In one line output two numbers — the height of the largest tower and their total number. Remember that Vasya should use all the bars.

Examples
input
Copy
`31 2 3`
output
Copy
`1 3`
input
Copy
`46 5 6 7`
output
Copy
`2 3`

Code Examples

#1 Code Example with C++ Programming

```Code - C++ Programming```

``````#include <cstdio>
#include <algorithm>

int main(){
int N; scanf("%d", &N);
int *length = new int[N];
for(int k = 0; k < N; k++){scanf("%d", length + k);}
std::sort(length, length + N);
int numTowers = 0, currentLength = 0, currentHeight = 1, maxHeight = 1;
for(int k = 0; k < N; k++){
if(length[k] == currentLength){currentHeight++; if(currentHeight > maxHeight){maxHeight = currentHeight;}}
else{currentLength = length[k]; currentHeight = 1; numTowers++;}
}
printf("%d %d\n", maxHeight, numTowers);
return 0;
}``````
Copy The Code &

Input

cmd
3
1 2 3

Output

cmd
1 3
Advertisements

Demonstration

Codeforces Solution-A. Towers-Solution in C, C++, Java, Python