C. Boxes Packing

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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 called visible iff it is not put into some another box.

Help Mishka to determine the minimum possible number of visible boxes!

Input

The first line contains one integer n (1 ≤ n ≤ 5000) — the number of boxes Mishka has got.

The second line contains n integers a1a2, ..., an (1 ≤ ai ≤ 109), where ai is the side length of i-th box.

Output

Print the minimum possible number of visible boxes.

Examples

input

3
1 2 3

output

1

input

4
4 2 4 3

output

2

 

题目大意:  小盒子可以放进比它大盒子,求这些盒子最后变成几个无法再组装的盒子

正常AC代码:

#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <ctype.h>
//******************************************************
#define lrt (rt*2)
#define rrt (rt*2+1)
#define LL long long
#define inf 0x3f3f3f3f
#define pi acos(-1.0)
#define exp 1e-8
//***************************************************
#define eps 1e-8
#define inf 0x3f3f3f3f
#define INF 2e18
#define LL long long
#define ULL unsigned long long
#define PI acos(-1.0)
#define pb push_back
#define mk make_pair #define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SQR(a) ((a)*(a))
#define Unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a) __typeof__(a.begin())
#define rIterator(a) __typeof__(a.rbegin())
#define FastRead ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi vector <int>
#define vL vector <LL>
#define For(I,A,B) for(int I = (A); I < (B); ++I)
#define FOR(I,A,B) for(int I = (A); I <= (B); ++I)
#define rFor(I,A,B) for(int I = (A); I >= (B); --I)
#define Rep(I,N) For(I,0,N)
#define REP(I,N) FOR(I,1,N)
using namespace std;
const int maxn=1e5+;
vector<int>Q[maxn];
const int MOD=1e9+;
int a[],vis[];
int k=; int main()
{
int n,x;
while(~scanf("%d",&n))
{
memset(vis,,sizeof(vis));
Rep(i,n) scanf("%d",&a[i]);
sort(a,a+n);
int ans=;
for(int i=;i<n;i++)
{
if(!vis[i])
{
x=a[i],vis[i]=;
for(int j=i+;j<n;j++)
{
if(!vis[j])
{
if(x<a[j])
{
x=a[j],vis[j]=;
}
}
}
ans++;
}
}
cout<<ans<<endl;
}
return ;
}

map巧用,贼短的代码:

#include<stdio.h>
#include<iostream>
#include<map>
#define For(I,A,B) for(int I = (A); I < (B); ++I)
#define FOR(I,A,B) for(int I = (A); I <= (B); ++I)
#define rFor(I,A,B) for(int I = (A); I >= (B); --I)
#define Rep(I,N) For(I,0,N)
#define REP(I,N) FOR(I,1,N)
using namespace std;
#define LL long long
const int maxn=+;
LL a[maxn],sum[maxn];
map<LL,LL>b;
LL num,Max;
int main()
{
int n;
while(~scanf("%d",&n))
{
b.clear();
Max=-;
REP(i,n)
{
scanf("%I64d",&num);
b[num]++;
Max=max(Max,b[num]);
}
cout<<Max<<endl;
}
return ;
}
 
 
 

Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing的更多相关文章

  1. 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. ...

  2. Educational Codeforces Round 34 (Rated for Div. 2) D - Almost Difference(高精度)

    D. Almost Difference Let's denote a function You are given an array a consisting of n integers. You ...

  3. 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 ...

  4. 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 ...

  5. Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块

    Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ​ ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  8. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  9. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

随机推荐

  1. 移动端web及app设计尺寸

    转载 2017年07月27日 22:48:16 984 移动端高清.多屏适配方案 背景 开发移动端H5页面 面对不同分辨率的手机 面对不同屏幕尺寸的手机 视觉稿 在前端开发之前,视觉MM会给我们一个p ...

  2. [BAT] 执行xcopy命令后出现Invalid num of parameters错误的解决办法

    如果是Windows下的命令行,对于有空格的文件路径要加引号,对于xcopy命令就是源路径和目标路径都要加引号 xcopy "C:\ppt" "D:\Program do ...

  3. 在Mockplus中,如何做鼠标悬停时菜单下拉的效果?

    了解Mockplus的用户会知道,该原型工具目前并不直接支持鼠标悬停功能.但我经过尝试,发现想用它实现一个鼠标悬停事件并不是什么难事,比如网页设计中很常见的鼠标悬停时菜单下拉的效果,只要换个思路,利用 ...

  4. Devexpress VCL Build v2014 vol 14.2.1 beta发布

    已经快到2015 年了. 14.2.1 beta 才出来了. 还好,有一些新东西. 官网地址 VCL Gauge Control Designed to clearly convey informat ...

  5. 【C#】VS2015开发环境的安装和配置(转)

    出处: http://www.cnblogs.com/rainmj/p/5636518.html http://www.cnblogs.com/rainmj/p/5636529.html http:/ ...

  6. Linux服务器部署系列之八—Sendmail篇

    Sendmail是目前Linux系统下面用得最广的邮件系统之一,虽然它存在一些不足,不过,目前还是有不少公司在使用它.对它的学习,也能让我们更深的了解邮件系统的运作.下面我们就来看看sendmail邮 ...

  7. linux安装mysql~~~mysql5.6.12

    Linux安装mysql服务器 准备: MySQL-client-5.6.12-1.rhel5.i386.rpm MySQL-server-5.6.12-1.rhel5.i386.rpm 首先检查环境 ...

  8. pyhthon lambda

    lambda x:x+1(1) >>>2 可以这样认为,lambda作为一个表达式,定义了一个匿名函数,上例的代码x为入口参数和出口参数,x+1为函数体,(1)为x的入口初始值, 用 ...

  9. (最小生成树) Building a Space Station -- POJ -- 2031

    链接: http://poj.org/problem?id=2031 Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6011 ...

  10. C++ 11可变参数接口设计在模板编程中应用的一点点总结

    概述 本人对模板编程的应用并非很深,若要用一句话总结我个人对模板编程的理解,我想说的是:模板编程是对类定义的弱化. 如何理解“类定义的弱化”? 一个完整的类有如下几部分组成: 类的名称: 类的成员变量 ...