A. 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 thanxi 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 test(s)
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

 二分pile的个数。
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <set>
using namespace std;
typedef long long LL ; int x[] , n ;
int pile[][] ;
int judge(int Len){
memset(pile,-,sizeof(pile)) ;
int row = n/Len , k = , i ,j;
for(i = ; i <= n/Len ; i++)
for(j = ; j <= Len ; j++)
pile[i][j] = x[k++] ;
if(n % Len){
row++ ;
j = ;
while(k < n)
pile[row][j++] = x[k++] ;
}
for(i = ; i <= Len ; i++){
for(j = ; j <= row ; j++){
if(pile[j][i] != - &&pile[j][i] < j - )
return ;
}
}
return ;
} int b_s(){
int L = ,R = n ,mid ,ans;
while(L <= R){
mid = (L + R)>> ;
if(judge(mid)){
ans = mid ;
R = mid - ;
}
else
L = mid + ;
}
return ans ;
} int main(){
int i ;
cin>>n ;
for(i = ; i < n ; i++)
cin>>x[i] ;
sort(x , x + n) ;
cout<<b_s()<<endl ;
return ;
}

Codeforces Round #228 (Div. 1) A的更多相关文章

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

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

  2. Codeforces Round #228 (Div. 1)

    今天学长给我们挂了一套Div.1的题,难受,好难啊. Problem A: 题目大意:给你n个数字,让你叠成n堆,每个数字上面的数的个数不能超过这个数,如 3 上面最多放三个数字 问你,最少能放几堆. ...

  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) A. Fox and Box Accumulation 贪心

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

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

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

  7. Codeforces Round #228 (Div. 2)

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

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

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

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

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

  10. Codeforces Round #228 (Div. 1) B

    B. Fox and Minimal path time limit per test 1 second memory limit per test 256 megabytes input stand ...

随机推荐

  1. opencv基本的数据结构(转)

    DataType : 将C++数据类型转换为对应的opencv数据类型 enum { CV_8U=0, CV_8S=1, CV_16U=2, CV_16S=3, CV_32S=4, CV_32F=5, ...

  2. 删除IE 下输入后的清除小叉叉

    input::-ms-clear { display: none; } css去掉ie10,11中input[type="text"]后面的X图标 input[type=" ...

  3. 网站优化之Asp.Net篇<一>

    一>禁用viewstate. 二>禁用动态编译.访问一个Aspx文件时 会编译为一个新的类放在C盘Asp.net临时文件夹下.下次请求不会再编译,会把先前的编译结果返回. 任何对Asp.n ...

  4. android 定时器AlarmManager

    1.android中通常是使用AlarmManager来定时启动一个单次或重复多次操作的.具体的说就是我们通过AlarmManager设定一个时间和注册一个intent到系统中,然后在该时间到来时,系 ...

  5. 2014年5月份第1周51Aspx源码发布详情

    郑州某高校学生考评系统源码  2014-5-5 [VS2008]功能介绍:   1.用户角色有部主任.教师.学生等.   2.可添加班级考评项目.学生考评项目.   3.可指定学生对班级.学生某考评项 ...

  6. Android中build target,minSdkVersion,targetSdkVersion,maxSdkVersion概念区分 (转载)

    本文参考了谷歌开发者文档:http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#provisional 如果 ...

  7. 期望DP

    BZOJ 1415 #include <iostream> #include <cstring> #include <algorithm> #include < ...

  8. Binary Tree Inorder Traversal -- LeetCode 94

    Given a binary tree, return the inorder traversal of its nodes' values. For example:Given binary tre ...

  9. Flask-DebugToolbar

    This extension adds a toolbar overlay to Flask applications containing useful information for debugg ...

  10. VC++ 文件系统

    using namespace System; using namespace System::IO; void ShowHelpMsg(){ Console::WriteLine(L"本程 ...