CF_37A_Towers
来源:互联网 发布:老年人意外伤害数据 编辑:程序博客网 时间:2024/06/06 19:36
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.
The first line contains an integer N (1 ≤ N ≤ 1000) — the number of bars at Vasya’s disposal. The second line containsN space-separated integers li — the lengths of the bars. All the lengths are natural numbers not exceeding1000.
In one line output two numbers — the height of the largest tower and their total number. Remember that Vasya should use all the bars.
31 2 3
1 3
46 5 6 7
2 3
简单模拟,计数找最大值即可
#include <iostream>#include <stdio.h>#include <string.h>using namespace std;const int M=1005;int len[M];int main(){ int n,num; int tot,lar,maxl; while(scanf("%d",&n)!=EOF) { memset(len,0,sizeof(len)); maxl=tot=lar=0; for(int i=0;i<n;i++) { scanf("%d",&num); len[num]++; maxl=max(maxl,num); } for(int i=1;i<=maxl;i++) { if(len[i]) { tot++; lar=max(lar,len[i]); } } printf("%d %d\n",lar,tot); } return 0;}
- CF_37A_Towers
- linux给命令取别名和为某些操作设置快捷键
- 关于就业指导和职业规划
- 表单前端验证+ajax异步请求
- An event-driven communication c# program
- Android:Toast 弹出信息框
- CF_37A_Towers
- A1077 Kuchiguse (20)
- Scala 深入浅出实战经典 第1讲 Scala开发环境搭建和HelloWorld解析
- android学习笔记(0)搭建android开发环境的前前后后
- IOS--UI--UIButton的使用
- 转:解决微信及360浏览器无法读取本地图片问题
- 关于JAVA Entity entity = entityClass.getAnnotation(Entity.class);
- 打造一款属于自己的Android滑动器
- 终于在windows下挑战编译安卓 chromium成功