Educational Codeforces Round 34 (Rated for Div. 2) C. Boxes Packing
C. Boxes Packing
time limit per test
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 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 a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the side length of i-th box.
Output
Print the minimum possible number of visible boxes.
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的更多相关文章
- 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) D - Almost Difference(高精度)
D. Almost Difference Let's denote a function You are given an array a consisting of n integers. You ...
- 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 (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 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块
Educational Codeforces Round 71 (Rated for Div. 2)-F. Remainder Problem-技巧分块 [Problem Description] ...
- 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 ...
- 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 ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
随机推荐
- Linux screen命令
一.简介 GNU Screen是一款由GNU计划开发的用于命令行终端切换的自由软件.用户可以通过该软件同时连接多个本地或远程的命令行会话,并在其间自由切换. GNU Screen可以看作是窗口管理器的 ...
- 使用RSA进行信息加密解密的WebService示例
使用RSA进行信息加密解密的WebService示例 按:以下文字涉及RSA对WebService传递的数据的加密解密,如果您已经熟知RSA或是有其它更好的方法请不要往下看以免浪费时间. WebSer ...
- JSONModel简便应用
JSONModel, Mantle 这两个开源库都是用来进行封装JSON->Model的, 想想看, 直接向服务器发起一个请求,然后回来后,就是一个Model, 直接使用, 这是一个多么美好的事 ...
- 2018.07.08 hdu1394 Minimum Inversion Number(线段树)
Minimum Inversion Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- asp.net web api 安装swagger
使用nuget控制台, 输入 Install-Package Swashbuckle,回车,等待安装引用.nuget国内没有镜像,安装比较慢 安装成功后会多出一个引用 右键工程点--属性,左边导航栏选 ...
- 39 What Determines the Kind of Person You Are ?是什么决定了你是哪种内型的人 ?
What Determines the Kind of Person You Are ?是什么决定了你是哪种内型的人 ? ①What determines the kind of person you ...
- [GO]kafka的生产者和消费者
生产者: package main import ( "github.com/Shopify/sarama" "fmt" "time" ) ...
- Linux创建其他用户并为之授权
转载自:https://www.linuxidc.com/Linux/2016-11/137549.htm:加了一些补充说明 前言 笔记本安装了一个CentOS,想要让别人也可以登录访问,用自己的账号 ...
- 用eclipse创建maven的webapp项目
来自http://www.cnblogs.com/candle806/p/3439469.html和http://blog.csdn.net/chuyuqing/article/details/288 ...
- virtualenv 安装及使用[转]
一如既往,官方文档: https://virtualenv.pypa.io/en/latest/ 下载地址:https://pypi.python.org/pypi/virtualenv#down ...