Codeforces Beta Round #37 A. Towers 水题

A. Towers

题目连接:

http://www.codeforces.com/contest/37/problem/A

Description

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.

Sample Input

3
1 2 3

Sample Output

1 3

Hint

题意

有n个木棍,如果木棍的长度一样的话,可以把它扔到上面,然后问你最高的是多高,以及有多少种木头

题解:

map,水题直接莽一波

代码

#include<bits/stdc++.h>
using namespace std;

map<int,int>H;
int main()
{
    int n;
    scanf("%d",&n);
    int ans=0,ans2=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(H[x]==0)ans2++;
        H[x]++;
        ans=max(ans,H[x]);
    }
    cout<<ans<<" "<<ans2<<endl;
}
    原文作者:qscqesze
    原文地址: https://www.cnblogs.com/qscqesze/p/5508888.html
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞