codeforces 37A Towers

来源:互联网 发布:印刷计价报价速算软件 编辑:程序博客网 时间:2024/06/03 11:17

点击打开链接

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
31 2 3
output
1 3
input
46 5 6 7
output
2 3

题意:给出n个栅栏,相同长度的叠放在一起,求最大的塔的高度及有多少个塔.
#include<stdio.h>#include<set>#include<map>#include<algorithm>using namespace std;int main(){    map<int,int>ff;    set<int>ss;    int n,s[1010];    scanf("%d",&n);    for(int i=0;i<n;i++)    {        scanf("%d",&s[i]);        ff[s[i]]++;        ss.insert(s[i]);    }    int ma=0;    for(int i=0;i<n;i++)    {        ma=max(ma,ff[s[i]]);    }    printf("%d %d\n",ma,ss.size());    return 0;}


原创粉丝点击