A. Fox and Box Accumulation
1 second
256 megabytes
standard input
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?
The first line contains an integer n (1 ≤ n ≤ 100).
The next line contains n integers x1, x2, ..., xn (0 ≤ xi ≤ 100).
Output a single integer — the minimal possible number of piles.
3
0 0 10
2
5
0 1 2 3 4
1
4
0 0 0 0
4
9
0 1 0 2 0 1 1 2 10
3
In example 1, one optimal way is to build 2 piles: the first pile contains boxes 1 and 3 (from top to bottom), the second pile contains only box 2.

In example 2, we can build only 1 pile that contains boxes 1, 2, 3, 4, 5 (from top to bottom).
解题说明:模拟题,须要从上向下构造一个箱子堆,经过排序之后,首先保证最上面的都是最小的,其次是以下一层,直到最后遍历结束。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include <algorithm>
#include<cstring>
#include<string>
using namespace std; int main()
{
int n, i, k, d[105];
k = 0;
cin >> n;
for (i = 0; i<n; i++)
{
cin >> d[i];
}
sort(d, d + n);
for (i = 0; i<n; i++)
{
if (k*(d[i] + 1) <= i)
{
k++;
}
}
cout << k << endl;
return 0;
}
A. Fox and Box Accumulation的更多相关文章
- Codeforces 388A - Fox and Box Accumulation
388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...
- 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 ...
- CodeForces 388A Fox and Box Accumulation (模拟)
A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...
- 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 ...
- codeforces A. Fox and Box Accumulation 解题报告
题目链接:http://codeforces.com/problemset/problem/388/A 题目意思:有 n 个 boxes,每个box 有相同的 size 和 weight,但是stre ...
- Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)
题目:http://codeforces.com/contest/389/problem/C 题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1: 很简单的贪心,比赛的时候没想出来.... ...
- 388A Fox and Box Accumulation
一开始贪心策略想错了! #include<cstdio> #include<algorithm> using namespace std; ]; int main() { in ...
- cf C. Fox and Box Accumulation
题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...
- 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 ...
随机推荐
- Boost下载安装编译配置使用指南
转载:http://www.cppblog.com/jerryma/archive/2011/10/17/158554.html --更新于2011/7/19,目前我已对boost的安装和使用有了新的 ...
- [转]Struts标签库详解
本文转自:http://hi.baidu.com/xzkcz/blog/item/5cf9f91f01beb9f4e0fe0bd4.html Struts提供了五个标签库,即:HTML.Bean. ...
- Java中的路径问题
Java中的路径问题 代码说明,如下: package com.merlin.test; import java.io.InputStream; public class Test { public ...
- 在logopond中看到的优秀设计随想
本随笔仅仅只是自己对于设计作品的想法,不喜勿喷~ 昨日看到关于大神配色的文章,决定在logopond网站中看看优秀的作品,以为自己的配色找找灵感,学习学习,对自己有很强的震撼力的有: 以女性高跟性的抽 ...
- (转)oracle字符集与汉字
Oracle与汉字问题与字符集 分类: oracle 2012-10-29 17:31 425人阅读 评论(0) 收藏 举报 Oracle字符集引起的几个问题,常见的就是汉字占多少个字节,其次就是字符 ...
- erlang 基础知识
一 数据类型 1. 整数 Integer Erlang可表示任意大的整数,大整数自动转换成bignums类型,比固定大小的整数类型相对效率较低. Base#Value 表示基数不是10的整数.如:2# ...
- delphi 判断调试状态
DebugHook 该变量在调试状态下值为1,运行模式为0,例如,我们可以使用如下的代码来简单控制: if DebugHook=0 then
- jBox使用方法
1.引入jquery文件 2.引入css和jBox文件 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml& ...
- HTML结构标签介绍
HTML:超文本标记语言 介绍HTML基本标记 1:头部标记(head)----- 头部的内容不会再页面上显示 在头部元素中,一般需要包括标题<title>,基本信息(文档样式, ...
- codeforces 659A Round House
A. Round House time limit per test 1 second memory limit per test 256 megabytes input standard input ...