Codeforces 388A Fox and Box accumulation (analog)

Source: Internet
Author: User


A. Fox and Box accumulationTime limit per test:1 secondmemory limit per test:256 megabytes

Fox Ciel had n boxes in her. They has the same size and weight, but they might has different strength. Thei-th box can hold at a most xI boxes in its top (we'll callx I the strength of the box).

Since all the boxes has the same size, Ciel cannot put more than one box directly on the top of the Some box. For example, imagine Ciel have three boxes:the first has strength 2, the second have 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 SEC Ond one. We'll call such a construction of boxes a pile.

Fox Ciel wants to construct piles from all the boxes. Each pile would contain some boxes from top to bottom, and there cannot is more thanxi boxes on The top ofI-th box. What's the minimal number of piles she needs to construct?

Input

The first line contains an integer n (1?≤? N? ≤?100). The next line containsn integers x1,? X2,?...,? xn (0?≤? Xi? ≤?100).

Output

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

Sample Test (s)Input
30 0 10
Output
2
Input
50 1 2) 3 4
Output
1
Input
40 0 0 0
Output
4
Input
90 1 0 2 0 1 1 2 10
Output
3
Note

In Example 1, one optimal-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).



Title Link: Http://codeforces.com/problemset/problem/388/A

The main topic: some boxes, the number represents the maximum can be put on the above, and the number above it can not be greater than the below, ask the least heap a few piles

Topic Analysis: Violence simulation, from the top down a pile of fetch, see the program notes in detail

#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;int a[105], hash[105]; int main () {    int n, MA =-1;    memset (hash, 0, sizeof (hash));    scanf ("%d", &n);    for (int i = 0; i < n; i++)    {        scanf ("%d", &a[i]);        MA = max (a[i], MA);        hash[a[i]]++;    }    int ans = 0;    while (n)    {        int cnt = 0;//The number of heap I for            (int i = 0; I <= ma; i++)        {            //has the current weight and its pressure is greater than or equal to the number above            /Then place it below while            (Hash[i] && i >= cnt)            {                hash[i]-;//Put one, the quantity minus 1                cnt++;      This number is added to 1                n-;       Record the total number of remaining            }        }        ans + +;  Record Heaps    }    printf ("%d\n", ans);}


Codeforces 388A Fox and Box accumulation (analog)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.