Educational Codeforces Round 34 C. Boxes Packing【模拟/STL-map/俄罗斯套娃】
1 second
256 megabytes
standard input
standard output
Mishka has got n empty boxes. For every i (1 ≤ i ≤ n), i-th box is a cube with side length ai.
Mishka can put a box i into another box j if the following conditions are met:
- i-th box is not put into another box;
- j-th box doesn't contain any other boxes;
- box i is smaller than box j (ai < aj).
Mishka can put boxes into each other an arbitrary number of times. He wants to minimize the number of visible boxes. A box is calledvisible iff it is not put into some another box.
Help Mishka to determine the minimum possible number of visible boxes!
The first line contains one integer n (1 ≤ n ≤ 5000) — the number of boxes Mishka has got.
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the side length of i-th box.
Print the minimum possible number of visible boxes.
3
1 2 3
1
4
4 2 4 3
2
In the first example it is possible to put box 1 into box 2, and 2 into 3.
In the second example Mishka can put box 2 into box 3, and box 4 into box 1.
【分析】:之前没用map而是hash就一直RE···当然思路就是找出出现次数最多的数的次数直接输出。
【代码】:
#include <iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<streambuf>
#include<cmath>
#include<string>
using namespace std;
#define ll long long
#define oo 10000000
const int N = +;
int a,m[N];
int ans;
/*
直接排序找出出现次数最多的那个数的次数直接输出
*/
int main()
{
int n;
int ma=-;
memset(m,,sizeof(m));
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d",&a);
m[a]++;
}
//sort(m,m+5000);
for(int i=;i<+;i++)
{
if(m[i]>ma)
ma=m[i];
}
printf("%d\n",ma);
return ;
}
RE代码
#include <bits/stdc++.h>
using namespace std;
int n, x, ma;
map<int,int> m;
int main()
{
cin >> n;
for (int i = ; i < n; i++)
{
cin >> x;
m[x]++;
ma = max(ma, m[x]);
}
printf("%d\n", ma);
}
AC代码
Educational Codeforces Round 34 C. Boxes Packing【模拟/STL-map/俄罗斯套娃】的更多相关文章
- Educational Codeforces Round 34 (Rated for Div. 2) A B C D
Educational Codeforces Round 34 (Rated for Div. 2) A Hungry Student Problem 题目链接: http://codeforces. ...
- Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
C. Boxes Packing time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 34 (Rated for Div. 2)
A. Hungry Student Problem time limit per test 1 second memory limit per test 256 megabytes input sta ...
- Educational Codeforces Round 34 D. Almost Difference【模拟/stl-map/ long double】
D. Almost Difference time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Educational Codeforces Round 34 B. The Modcrab【模拟/STL】
B. The Modcrab time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Educational Codeforces Round 34 (Rated for Div. 2) B题【打怪模拟】
B. The Modcrab Vova is again playing some computer game, now an RPG. In the game Vova's character re ...
- Educational Codeforces Round 2 A. Extract Numbers 模拟题
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...
- Educational Codeforces Round 11B. Seating On Bus 模拟
地址:http://codeforces.com/contest/660/problem/B 题目: B. Seating On Bus time limit per test 1 second me ...
- Educational Codeforces Round 34
F - Clear The Matrix 分析 题目问将所有星变成点的花费,限制了行数(只有4行),就可以往状压DP上去靠了. \(dp[i][j]\) 表示到第 \(i\) 列时状态为 \(j\) ...
随机推荐
- 动态规划:HDU2844-Coins(多重背包的二进制优化)
Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- 【转】Oracle AWR 报告 每天自动生成并发送邮箱 Python脚本(一)
Oracle 的AWR 报告能很好的提供有关DB性能的信息. 所以DBA 需要定期的查看AWR的报告. 有关AWR报告的说明参考: Oracle AWR 介绍 http://blog.csdn.net ...
- 3 View视图 URLconf
1.视图 视图接受Web请求并且返回Web响应 视图就是一个python函数,被定义在views.py中 响应可以是一张网页的HTML内容,一个重定向,一个404错误等等 响应处理过程如下图: 2 准 ...
- 如何排查Java内存泄漏?看完我给跪了!
没有经验的程序员经常认为Java的自动垃圾回收完全使他们免于担心内存管理.这是一个常见的误解:虽然垃圾收集器做得很好,但即使是最好的程序员也完全有可能成为严重破坏内存泄漏的牺牲品.让我解释一下. 当不 ...
- jmeter全局变量配置:将token运用到全局(跨线程组使用变量)
请注意元器件的执行顺序: 请将提取token的配置原件放在设置全局变量的配置元器件前面(本来是一个超级马虎的人,真是俗称“方脑壳”啊) 1.获取登录后的token(提取可以用json path Ext ...
- MySQL一对一:一对多:多对多
学生表和课程表可以多对多 一个学生可以学多门课程 一门课程可以有多个学生: 多对多 *** 一个学生对应一个班级 一个班级对应多个学生: 一对多 *** 一个老师对应多个学生 多个学生对应一个老师:一 ...
- Redis的 SORT命令
SORT key [BY pattern] [LIMIT offset count] [GET pattern [GET pattern ...]] [ASC | DESC] [ALPHA] [S ...
- 精通CSS高级Web标准解决方案(5、对列表应用样式和创建导航条)
5.1基本样式列表 去掉列表的默认样式: ul{ margin:; padding:; list-style-type:none; } 添加定制的符号,在列表左边添加填充,为符号留出空间,然后将符号图 ...
- python矩阵和向量的转置问题
numpy有很多方法进行转置,这里由于时间和精力限制(主要是我实在比较懒,有一个基本上一直能使的,就懒得看其他的了),其他方法我没研究,这里我总结的东西,如果有问题,欢迎各路大佬拍砖 一.创建矩阵: ...
- 【转】log4js在PM2的cluster模式下大坑
请直接查看原文:https://blog.yourtion.com/fix-log4js-with-pm2-not-work.html 之前一直使用 debug 还有 console.log 去打日志 ...