A. Fox and Box Accumulation

题目连接:

http://codeforces.com/contest/388/problem/A

Description

Fox Ciel has n boxes in her room. They have the same size and weight, but they might have different strength. The i-th box can hold at most xi boxes on its top (we'll call xi the strength of the box).

Since all the boxes have the same size, Ciel cannot put more than one box directly on the top of some box. For example, imagine Ciel has three boxes: the first has strength 2, the second has strength 1 and the third has strength 1. She cannot put the second and the third box simultaneously directly on the top of the first one. But she can put the second box directly on the top of the first one, and then the third box directly on the top of the second one. We will call such a construction of boxes a pile.

Fox Ciel wants to construct piles from all the boxes. Each pile will contain some boxes from top to bottom, and there cannot be more than xi boxes on the top of i-th box. What is the minimal number of piles she needs to construct?

Input

The first line contains an integer n (1 ≤ n ≤ 100). The next line contains n integers x1, x2, ..., xn (0 ≤ xi ≤ 100).

Output

Output a single integer — the minimal possible number of piles.

Sample Input

3

0 0 10

Sample Output

2

Hint

题意

有n个箱子,现在对于每一个箱子告诉你这个箱子的上面最多放多少个箱子

现在你需要使得箱子的列数最小,请问是多少

题解:

从表象来说,感觉像一个多背包问题,但实质上是不是的

这个东西显然是可以贪心的,因为这个箱子你用还是不用,对下一个用啥是没有影响的

所以直接贪心就好了

代码

#include<bits/stdc++.h>
using namespace std; const int maxn = 105;
int vis[maxn],ans;
int a[maxn];
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
sort(a+1,a+1+n);
for(int i=1;i<=n;i++)
{
int pre = -1;
for(int j=i;j<=n;j++)
{
if(vis[j])continue;
if(a[j]>pre)
{
vis[j]=1;
pre++;
}
}
if(pre!=-1)ans++;
}
cout<<ans<<endl;
}

Codeforces Round #228 (Div. 1) A. Fox and Box Accumulation 贪心的更多相关文章

  1. Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation

    C. Fox and Box Accumulation time limit per test 1 second memory limit per test 256 megabytes input s ...

  2. Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)

    题目:http://codeforces.com/contest/389/problem/C 题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1: 很简单的贪心,比赛的时候没想出来.... ...

  3. Codeforces Round #228 (Div. 1) C. Fox and Card Game 博弈

    C. Fox and Card Game 题目连接: http://codeforces.com/contest/388/problem/C Description Fox Ciel is playi ...

  4. Codeforces Round #228 (Div. 1) B. Fox and Minimal path 构造

    B. Fox and Minimal path 题目连接: http://codeforces.com/contest/388/problem/B Description Fox Ciel wants ...

  5. Codeforces Round #228 (Div. 1) 388B Fox and Minimal path

    链接:http://codeforces.com/problemset/problem/388/B [题意] 给出一个整数K,构造出刚好含有K条从1到2的最短路的图. [分析] 由于是要自己构造图,当 ...

  6. Codeforces Round #228 (Div. 2) B. Fox and Cross

    #include <iostream> #include <string> #include <vector> #include <algorithm> ...

  7. Codeforces Round #228 (Div. 2) A. Fox and Number Game

    #include <iostream> #include <algorithm> #include <vector> #include <numeric> ...

  8. Codeforces Round #228 (Div. 2)

    做codeforces以来题目最水的一次 A题: Fox and Number Game 题意:就是用一堆数字来回减,直到减到最小值为止,再把所有最小值加,求这个值 sol: 简单数论题目,直接求所有 ...

  9. Codeforces Round #228 (Div. 1) A

    A. Fox and Box Accumulation time limit per test 1 second memory limit per test 256 megabytes input s ...

随机推荐

  1. 002_IO磁盘深入理解

    一.如何测试云硬盘 https://www.ustack.com/blog/how-benchmark-ebs/#fio

  2. linux终端操作快捷键

    终端操作快捷键: 新建家目录下终端窗口:Ctrl+Alt+t在当期当前路径下新建终端窗口:Ctrl+Shift+n退出终端窗口:Ctrl+Shift+q 多个终端窗口之间相互切换:Tab+Alt 终端 ...

  3. wpf 在Popup内的TextBox 输入法 不能切换

    切换输入法 输入不了中文 [DllImport("User32.dll")] public static extern IntPtr SetFocus(IntPtr hWnd); ...

  4. 20165301 2017-2018-2《Java程序设计》课程总结

    20165301 2017-2018-2<Java程序设计>课程总结 每周作业链接汇总 预备作业1:我期待的师生关系 预备作业2:学习基础与c语言学习心得 预备作业3: Linux安装及命 ...

  5. SQL语句添加删除修改字段

    用SQL语句添加删除修改字段1.增加字段     alter table docdsp    add dspcodechar(200)2.删除字段     ALTER TABLE table_NAME ...

  6. 最邻近规则分类KNN算法

    例子: 求未知电影属于什么类型: 算法介绍: 步骤:  为了判断未知实例的类别,以所有已知类别的实例作为参照      选择参数K      计算未知实例与所有已知实例的距离      选择最近K个已 ...

  7. appium----adb shell输入中文/Emoji表情符(ADBKeyBoard)

    前序 “adb shell input textyoyo“ 可以通过adb 输入英文的文本,由于不支持unicode编码,所以无法输入中文,github上有个国外的大神写了个ADBKeyBoard输入 ...

  8. 如何在k8s集群里快速运行一个镜像?

    在docker里,快速run一个镜像,很简单的. k8s的世界,与之类似. 但要注意一下,如果镜像本身没有提供command命令,这个容器由于前台输出完成,很快就退出了. 所以,遇到这种镜像,就最好自 ...

  9. 解决Linux中文显示乱码的问题

    1.直接执行 export LC_ALL=zh_CN.UTF8 #linux服务器中文显示乱码,但配置文件设置是中文的.解决办法 2.修改文件 修改/etc/sysconfig/i18n文件,确认信息 ...

  10. Rookey.Frame企业级快速开发框架开源了

    Rookey.Frame是一套基于.NET MVC + easyui的企业级极速开发框架,支持简单逻辑模块零代码编程.支持工作流(BPM).支持二次开发,具有高扩展性.高复用性.高伸缩性:应广大网友要 ...