CF228C题Fox and Box Accumulation

2024-08-24 22:32
文章标签 cf228c fox box accumulation

本文主要是介绍CF228C题Fox and Box Accumulation,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

史无前例的做出C题啊!!!激动ing~~。。。

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
Note

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 <stdio.h>
int main()
{int n, a[101], i, j, x, s, b[101]= {0}, z = 0, y = 0;scanf("%d",&n);s=n;for(i=0; i<n; i++){scanf("%d",&a[i]);b[a[i]]++;if(y<a[i])y=a[i];}while(s){x=0;for(i=0; i<=y; i++){while(b[i]&&i>=x){x++;b[i]--;s--;}}z++;}printf("%d\n",z);return 0;
}


这篇关于CF228C题Fox and Box Accumulation的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1103784

相关文章

论文翻译:ICLR-2024 PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS

PROVING TEST SET CONTAMINATION IN BLACK BOX LANGUAGE MODELS https://openreview.net/forum?id=KS8mIvetg2 验证测试集污染在黑盒语言模型中 文章目录 验证测试集污染在黑盒语言模型中摘要1 引言 摘要 大型语言模型是在大量互联网数据上训练的,这引发了人们的担忧和猜测,即它们可能已

Hack The Box-Infiltrator【更新中】

信息收集&端口利用 nmap -sSVC infiltrator.htbStarting Nmap 7.94SVN ( https://nmap.org ) at 2024-09-02 09:17 CSTNmap scan report for infiltrator.htbHost is up (0.61s latency).Not shown: 987 filtered tcp por

CSS行元素的截断样式box-decoration-break属性,有点儿意思!

原文地址:原文连接 在CSS中,行元素默认情况下,行内元素不会独占一行,而是在一行内根据其内容的大小进行排列。行内元素的宽度和高度由其内容决定,不能直接设置宽度和高度。行内元素不能包含块级元素,只能包含其他行内元素或文本。行内元素可以设置水平方向的边距(margin)和内边距(padding),但不会影响到其他元素的布局。 常用行内元素:a、span、i、em、strong、img等。 一、

【数学】 HDU 1110 Equipment Box

WA了很多遍,很多遍。。。只要把输入改成double就对了。。无语凝噎。。。 #include <stdio.h>#include <iostream>#include <string>#include <cstring>#include <math.h>#include <cmath>using namespace std;#define PI 2 * asin(1.0

CSS3 文本效果(text-shadow,box-shadow,white-space等)

一 text-shadow text-shadow 属性是 CSS3 中用于为文本添加阴影效果的工具。它可以增强文本的可读性和视觉吸引力,提供丰富的视觉效果 1 语法 text-shadow: offset-x offset-y blur-radius color; offset-x:阴影相对于文本的水平偏移量。可以是正值(向右偏移)或负值(向左偏移)。offset-y:阴影相对于文本的

box-shadow属行

‌‌box-shadow‌是‌CSS3中的一个属性,用于在元素上创建外部或内部阴影效果。它允许开发者为元素添加一个或多个阴影,每个阴影通过距元素的‌X和Y偏移、‌模糊半径、‌扩散半径、‌颜色和‌不透明度值来指定。这个属性对于增强元素的视觉效果和立体感非常有用。 基本语法 box-shadow属性的基本语法如下: cssCopy Code box-shadow: h-shadow

css3 box-shadow 内阴影与外阴影

css3 box-shadow 内阴影与外阴影   1- box-shadow具体使用方法,语法:   E {box-shadow:inset x-offset y-offset blur-radius spread-radiuscolor} 换句说: 对象选择器 {text-shadow:投影方式 X轴偏移量 Y轴偏移量 阴影模糊半径 阴影扩展半径 阴影颜色}   取值:投放方式

图片生成box-shadow并下载

把图片生成由box-shadow拼接成的阴影组成的图片 html <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>图片生成阴影html</title>

virtual box安装centos8.3最新版

主要步骤: 1.下载virtual box :官网下载地址:virtualbox 2.我下载的是window版,下载完,直接安装,点下一步安装完成即可 3.下载centos安装镜像:cenos下载地址:centos linux为稳定版,stream为体验版:参考:linux和strean的区别 4.8.3版开始不提供mini镜像,这里选择下载boot镜像,700M左右 5.开始安装 点击确

Virtual box安装CentOS8

Virtual Box 安装CentOS8 1.下载链接 Virtual box下载地址:https://www.virtualbox.org/wiki/Downloads SmarTTY下载地址:http://sysprogs.com/SmarTTY/download/ centos8下载地址:http://mirrors.aliyun.com/centos/8/isos/x86_64/