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 test(s)
input
3
1 2 3
output
1 3
input
4
6 5 6 7
output
2 3

题意就是计算一个数组中的最大反复数和去重后的数据量。

所以本题就是数组去重知识的运用,和添加一个记录,记录最大反复数。

void Towers()
{
unsigned n;
cin>>n;
int *A = new int[n]; for (unsigned i = 0; i < n; i++)
{
cin>>A[i];
}
sort(A, A+n);
int j = 1, h = 1, max_h = 1;
for (unsigned i = 1; i < n; i++)
{
if (A[i] != A[i-1])
{
A[j++] = A[i];
max_h = max(max_h, h);
h = 1;
}
else h++;
}
max_h = max(max_h, h);
cout<<max_h<<' '<<j; delete [] A;
}

codeforces Towers 题解的更多相关文章

  1. codeforces#536题解

    CodeForces#536 A. Lunar New Year and Cross Counting Description: Lunar New Year is approaching, and ...

  2. codeforces 1093 题解

    12.18 update:补充了 $ F $ 题的题解 A 题: 题目保证一定有解,就可以考虑用 $ 2 $ 和 $ 3 $ 来凑出这个数 $ n $ 如果 $ n $ 是偶数,我们用 $ n / 2 ...

  3. Codeforces Numbers 题解

    这题只需要会10转P进制就行了. PS:答案需要约分,可以直接用c++自带函数__gcd(x,y). 洛谷网址 Codeforces网址 Code(C++): #include<bits/std ...

  4. Codeforces 691E题解 DP+矩阵快速幂

    题面 传送门:http://codeforces.com/problemset/problem/691/E E. Xor-sequences time limit per test3 seconds ...

  5. Codeforces 833B 题解(DP+线段树)

    题面 传送门:http://codeforces.com/problemset/problem/833/B B. The Bakery time limit per test2.5 seconds m ...

  6. Codeforces 840C 题解(DP+组合数学)

    题面 传送门:http://codeforces.com/problemset/problem/840/C C. On the Bench time limit per test2 seconds m ...

  7. Codeforces 515C 题解(贪心+数论)(思维题)

    题面 传送门:http://codeforces.com/problemset/problem/515/C Drazil is playing a math game with Varda. Let’ ...

  8. Codeforces 475D 题解(二分查找+ST表)

    题面: 传送门:http://codeforces.com/problemset/problem/475/D Given a sequence of integers a1, -, an and q ...

  9. CodeForces CF875C题解

    题解 非常有意思的\(2-SAT\)的题. 听学长讲完之后感觉确实容易想到\(2-SAT\),顺理成章. 显然,对于两个串,对咱们来说有意义的显然是两个串中第一个不同的数字.那么,我们假设两个串分别是 ...

随机推荐

  1. JavaScript:目录

    ylbtech-JavaScript:目录 1. https://www.javascript.com/ 2. 1.返回顶部 1. http://www.runoob.com/js/js-functi ...

  2. C# 线程知识汇总

    一.基本概念 进程(process)是windows系统中你的一个基本概念,它包含着一个运行程序所需要的资源.一个正在运行的应用程序在操作系统中被视为一个进程,进程可以包括一个或者多个线程.线程是操作 ...

  3. tab选项卡切换(js原生、jQuery )

    思路: ① 遍历Tab选项 ② 然后给每个Tab选项绑定点击事件 ③ 每次点击时清除所有Tab选项及Tab选项内容的样式,然后给当前Tab选项添加标记样式,给当前Tab选项添加显示样式 <!DO ...

  4. Python操作Oracle

    [root@oracle02 pythonsoftware]# rpm -ivh oracle-instantclient-basic-11.1.0.1-1.x86_64.rpm Preparing. ...

  5. 行间事件传this的问题:

    在做1个简单功能的时候,行间事件这块发现了1个问题: <!doctype html> <html> <head> <meta charset="ut ...

  6. atom安装与插件配置

    下载:https://atom.io 安装 必备插件安装步骤: File-->settings-->Install-->Install Packages下面的输入框中输入要安装的插件 ...

  7. JS 用+1、-1填12()34()56()78()9=59

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  8. 发现被坑了,从来没看到说java的Date一旦实例化时间就不会变了

    java中使用Date对象获取系统当前时间,然而我就没看到哪篇教程告诉我说Date创建对象之后其中的时间是不会变的!!! 一开始我写了类似于下边这样的代码,希望每隔一段时间显示一次时间 Date d= ...

  9. WEBGL学习【六】动起来的三棱锥和立方体

    <html lang="zh-CN"> <!--服务器运行地址:http://127.0.0.1:8080/webgl/LearnNeHeWebGL/NeHeWe ...

  10. VUE 利用 webpack 给生产环境和发布环境配置不同的接口地址

    转载地址: https://blog.csdn.net/gebitan505/article/details/58166055 VUE 利用 webpack 给生产环境和发布环境配置不同的接口地址 前 ...