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\) ...
随机推荐
- ASP.NET Core 利用中间件支持跨域请求
方法1: 在Startup的ConfigureServices()中添加services.AddCors()在Startup的Configure()中添加app.UseCors(); 保证其在app. ...
- alert(1) to win部分解题
XSS在线习题分析 (https://alf.nu/alert1) 1. Warmup function escape(s) { return '<script>console.log(& ...
- Leetcode 560.和为k的子数组
和为k的子数组 给定一个整数数组和一个整数 k,你需要找到该数组中和为 k 的连续的子数组的个数. 示例 1 : 输入:nums = [1,1,1], k = 2 输出: 2 , [1,1] 与 [1 ...
- Linux下librtmp使用及编程实战
最近想做rtmp的推流.直播的小项目,不想直接使用FFmpeg进行推流,FFmpeg进行推流特别简单,因为它已经将编码以及librtmp都集成好了,没啥意思.FFmpeg推流的例子,在雷神的博客里可以 ...
- 实战小项目之嵌入式linux图像采集与传输
项目简介 本次编程实战主要是围绕嵌入式linux v4l2采集框架展开,包括以下几个部分: v4l2视频采集 IPU转码 framebuffer显示 自定义UDP简单协议进行传输 上位机软件 ...
- redhat-2
2016年5月16日-工作日志1 通过PXE安装RHEL7.2系统,部署satellite6.2(采用不是least-stable版本,是Satellite-6.2.0-RHEL-7-20160512 ...
- 如何删除本地docker images镜像
背景 本地空间较小,想删除无效的docker镜像内容. 操作步骤 查看本地docker镜像 尝试删除本地镜像 发现无法直接删除镜像 原因分析: 有关联docker容器,无法删除 删除docker容器 ...
- jquery怎样获取html页面中的data-xxx
$(this).attr("data-id") // will return the string "123"or .data() (if you use ne ...
- vue - computed
computed 的作用主要是对原数据进行改造输出.改造输出:包括格式的编辑,大小写转换,顺序重排,添加符号……. 一.格式化输出结果: 我们先来做个读出价格的例子:我们读书的原始数据是price:1 ...
- Log4j官方文档翻译(七、日志格式化)
apache log4j提供各种layout对象,然后根据自己指定的layouts对象转化日志信息.通常来说都是应用量身定制layout对象转换信息格式. 所有的layout对象从Appender对象 ...