C. Fox and Box Accumulation
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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.

Examples
input
3
0 0 10
output
2
input
5
0 1 2 3 4
output
1
input
4
0 0 0 0
output
4
input
9
0 1 0 2 0 1 1 2 10
output
3

这题的贪心得逆向考虑,就是从小到大贪心,先看小的 a[i]值,看后面有没有能承受住这个箱子的其他箱子,如果有那么叠加箱子的数量,接着找。

/* ***********************************************
Author :guanjun
Created Time :2016/8/10 22:51:00
File Name :cf228c.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
int a[maxn];
int vis[maxn];
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
cle(vis);
cin>>n;
for(int i=;i<=n;i++)cin>>a[i];
sort(a+,a++n);
int ans=;
for(int i=;i<=n;i++){
if(!vis[i]){
int num=;
for(int j=i+;j<=n;j++){
if(a[j]>=num&&!vis[j]){
num++;vis[j]=;
}
}
ans++;
}
}
cout<<ans<<endl;
return ;
}

Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation的更多相关文章

  1. Codeforces Round #228 (Div. 1) A. Fox and Box Accumulation 贪心

    A. Fox and Box Accumulation 题目连接: http://codeforces.com/contest/388/problem/A Description Fox Ciel h ...

  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. mysql通配符进行模糊查询

    在mysql数据库中,当我们需要模糊查询的时候 ,我们会使用到通配符. 首先我们来了解一下2个概念,一个是操作符,一个是通配符. 操作符 like就是SQL语句中的操作符,它的作用是指示在SQL语句后 ...

  2. composer install提示需要输入账号解决方法

    1.问题描述:输入composer install提示需要输入账号,如下所示: 2.解决方法,改用社区的源:composer config -g repo.packagist composer htt ...

  3. Linux命令学习(5):more和less

    引子 平常工作中经常需要查看很大的文本文件,如果用vi打开的话会非常慢,所以平常都用less,但是并没有很系统地学习过less的用法,今天总结一下less和more的用法. 经过学习我发现less比m ...

  4. stark组件之时间插件(九)

    在模型model中用的都是时间字段DateTimeField字段,在后台处理中可以看到,在生成modelform过程中,继承的是BaseModelForm,而其对时间字段加入了特殊的date_time ...

  5. 集训第六周 数学概念与方法 J题 数论,质因数分解

    Description Tomorrow is contest day, Are you all ready? We have been training for 45 days, and all g ...

  6. Wireshark抓包工具的简单使用1(界面介绍)

    Wireshark安装完成后,就可以打开,具体运行界面如下 一.菜单——用于开始操作 File ——包括打开.合并捕捉文件,save/保存,Print/打印,Export/导出捕捉文件的全部或部分.以 ...

  7. Jmeter&Ant构建自动化测试平台

    JMeter是一个软件,使负载测试或业绩为导向的业务(功能)测试不同的协议或技术. Apache软件基金会的Stefano Mazzocchi JMeter的最初的开发.他写道:它主要对 Apache ...

  8. loadrunner-3个难点

    1.loadrunner 监控windows资源 2.loadrunner如何实现如下: 1.1.1.1 场景一 10进程同时新增用户 测试场景说明:10进程新增用户, 第一个进程从1到1000,第二 ...

  9. HDU 5458 Stability

    Stability Time Limit: 2000ms Memory Limit: 102400KB This problem will be judged on HDU. Original ID: ...

  10. POJ-3041 Asteroids,二分匹配解决棋盘问题。

    Asteroids Time Limit: 1000MS   Memory Limit: 65536K       Description Bessie wants to navigate her s ...