388A.md (2106B)
1 Source: https://codeforces.com/problemset/problem/388/A 2 3 A. Fox and Box Accumulation 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 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 *x**i* boxes on its top (we'll call *x**i* the strength of the box). 22 23 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. 24 25  26 27 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 *x**i* boxes on the top of *i*-th box. What is the minimal number of piles she needs to construct? 28 29 Input 30 31 The first line contains an integer *n* (1 ≤ *n* ≤ 100). The next line contains *n* integers *x*1, *x*2, ..., *x**n* (0 ≤ *x**i* ≤ 100). 32 33 Output 34 35 Output a single integer — the minimal possible number of piles. 36 37 Examples 38 39 Input 40 41 ``` 42 3 43 0 0 10 44 ``` 45 46 Output 47 48 ``` 49 2 50 ``` 51 52 Input 53 54 ``` 55 5 56 0 1 2 3 4 57 ``` 58 59 Output 60 61 ``` 62 1 63 ``` 64 65 Input 66 67 ``` 68 4 69 0 0 0 0 70 ``` 71 72 Output 73 74 ``` 75 4 76 ``` 77 78 Input 79 80 ``` 81 9 82 0 1 0 2 0 1 1 2 10 83 ``` 84 85 Output 86 87 ``` 88 3 89 ``` 90 91 Note 92 93 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. 94 95  96 97 In example 2, we can build only 1 pile that contains boxes 1, 2, 3, 4, 5 (from top to bottom). 98 99 