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;
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 上周热点回顾(1.20-1.26)
· 【译】.NET 升级助手现在支持升级到集中式包管理
2015-05-19 luoguoj 1598 垂直柱状图 模拟
2015-05-19 bzoj 4001 [TJOI2015]概率论 数学
2015-05-19 bzoj 4010: [HNOI2015]菜肴制作 拓扑排序
2015-05-19 uoj 67 新年的毒瘤 tarjan求割点
2015-05-19 uoj 66 新年的巧克力棒 数学