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\) ...
随机推荐
- Linux命令之---mv
命令简介 mv命令是move的缩写,可以用来移动文件或者将文件改名(move (rename) files) 命令格式 mv [选项] 源文件或目录 目标文件或目录 命令参数 -b 若需覆盖文件,则覆 ...
- loj2057 「TJOI / HEOI2016」游戏
记横联通是一块横着的没有硬石头的地,把他们编号.竖联通同理. 对于一个空地,将其横联通编号和竖联通编号连边,二分图匹配,最大匹配为答案. #include <iostream> #incl ...
- Python+Selenium练习篇之1-摘取网页上全部邮箱
前面已经介绍了Python+Selenium基础篇,通过前面几篇文章的介绍和练习,Selenium+Python的webUI自动化测试算是入门了.接下来,我计划写第二个系列:练习篇,通过一些练习,了解 ...
- Android App程序结构
先看结构图: ====================================== 1. /src 源码目录,不解释. 2. /gen gen目录是ADT 自动生成的代码所在位置 ...
- (转载)django 访问url报错Forbidden (CSRF cookie not set.): xxx 问
原地址:http://www.cnblogs.com/meitian/p/7016336.html 问题:页面访问时报错 Forbidden (CSRF cookie not set.): xxx ...
- BZOJ 1855: [Scoi2010]股票交易(DP+单调队列)
1855: [Scoi2010]股票交易 Description 最近lxhgww又迷上了投资股票,通过一段时间的观察和学习,他总结出了股票行情的一些规律. 通过一段时间的观察,lxhgww预测到了未 ...
- Quotes
A man's gotta do what a man's gotta do.
- 标准IO与文件IO 的区别
先来了解下什么是标准IO以及文件IO. 标准IO:标准I/O是ANSI C建立的一个标准I/O模型,是一个标准函数包和stdio.h头文件中的定义,具有一定的可移植性.标准IO库处理很多细节.例如缓存 ...
- 洛谷P1135 奇怪的电梯
题目描述 呵呵,有一天我做了一个梦,梦见了一种很奇怪的电梯.大楼的每一层楼都可以停电梯,而且第i层楼 (1<=i<=N)上有一个数字Ki(0<=Ki<=N).电梯只有四个按钮: ...
- Entity Framework context per request
原文发布时间为:2011-09-24 -- 来源于本人的百度文章 [由搬家工具导入] http://www.blog.cyberkinetx.com/2011/05/15/entity-framewo ...