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& ...
随机推荐
- db2 sql调优
当我们发现某个SQL语句执行很慢时,可以通过查看它的访问计划来定位原因,如是否执行了合适的索引.是否采用了正确的连接方法等.但是我们发现很多用户对访问计划的生成和解释工具的使用存在很多疑惑,本文通过一 ...
- 现代编译原理--第二章(语法分析之LR(1))
(转载请表明出处 http://www.cnblogs.com/BlackWalnut/p/4472772.html) 前面已经介绍过LL(1),以及如何使用LL(1)文法.但是LL(K)文法要求在 ...
- abort: no username supplied (see "hg help config")
abort: no username supplied (see "hg help config") 在hg中输入commit 指令时,如果出现下述结果: $ hg commit ...
- Debian Buster Nginx 布署 Brophp 项目(类 Thinkphp)
1 材料 debian buster nginx a project that develop base brophp 2 步骤 配置文件 /etc/nginx/sites-available/pis ...
- DB2 create into的用法
. 建立表 create table zjt_tables as (select * from tables) definition only; create table zjt_views as ( ...
- KOBAS
1. What is KOBAS 3.0? KOBAS (KEGG Orthology Based Annotation System) is a web server for gene/protei ...
- =default(c++11)
1.概念 1)如果我们需要编译器默认的行为,则可以在参数列表后面加上=default来显式地要求编译器生成合成版本的默认构造函数和拷贝控制成员:合成的默认构造函数.合成拷贝构造函数.合成拷贝赋值运算符 ...
- 通过wsdl生成client 的几种方式
wsimport 位置 %JAVA_HOME%/bin/wsimport.exe 帮助 wsimport -help Usage: wsimport [options] <WSDL_URI> ...
- eclipse中java build path下 allow output folders for source folders 无法勾选,该如何解决 eclipse中java build path下 allow output folders for source folders 无法勾选,
在创建maven工程时,在设置output folders时,总是勾选以后,老是自动恢复到原来的状态,对比其他的maven的工程发现是在创建maven时候选择的项目为pom,而不是war或者jar,将 ...
- C#之23中设计模式
本身打算把二十三种设计模式,总结一下.总结了几个设计模式后发现已经有博主总结的非常详细,内容丰富,我看了后也是受益良多.大家可以参考他的博客,地址如下: https://www.cnblogs.com ...