• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Codeforce Round #227 Div2 C

 

Sponsored by
In English По-русски
HaibaraAi | Logout
 
 
 
 
 
  • Home
  • Contests
  • Gym
  • Problemset
  • Groups
  • Rating
  • Help

 
 
Codeforces Round #228 (Div. 2)
Finished
Practice
Add to favourites
 
 
→ Practice
 
You are registered for practice. You can solve problems unofficially. Results can be found in the contest status and in the bottom of standings.
 
 
→ Submit?
 
Language:
Choose file:
Be careful: there is 50 points penalty for submission which fails the pretests or resubmission (except failure on the first test, denial of judgement or similar verdicts). "Passed pretests" submission verdict doesn't guarantee that the solution is absolutely correct and it will pass system tests.
 
 
→ Last submissions
 
SubmissionTimeVerdict
5913055 02/07/2014 12:41AM Time limit exceeded on test 1
5913049 02/07/2014 12:40AM Accepted
5911696 02/06/2014 08:35PM Wrong answer on test 10
 
 
→ Problem tags
 
 
 
 
 
binary search
 
 
 
 
greedy
 
 
 
 
sortings
No tag edit access
 
 
→ Contest materials
 
  • Announcement
     
  • Tutorial
     
  •  
     
     
  • Problems
  • Submit
  • My submissions
  • Status
  • Hacks
  • Room
  • Standings
  • Custom test
C. 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 than xi 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).


Codeforces (c) Copyright 2010-2014 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: 02/07/2014 12:43AM (p1).
 
 
 
 1 #pragma comment(linker,"/STACK:102400000,102400000")
 2 #include <cstdio>
 3 #include <vector>
 4 #include <cmath>
 5 #include <queue>
 6 #include <set>
 7 #include <cstring>
 8 #include <iostream>
 9 #include <algorithm>
10 using namespace std;
11 #define INF 0x7fffffff 
12 #define mod 1000000007
13 #define ll long long
14 #define maxn 205
15 #define pi acos(-1.0)  
16 int n, m, k, c,t,b;
17 int a[maxn];
18 int main(){
19     int x;
20     scanf("%d", &n);
21     for (int i = 0; i < n; i++)scanf("%d", &x),a[x+1]++;
22     while (1){
23         k++;
24         t = 0;
25         for (int i = 0; i <= 101; i++)
26             while (t < i&&a[i])t++, a[i]--;
27         t = 0;
28         for (int i = 0; i <= 100; i++)t += a[i];
29         if (t == 0)break;
30     }
31     printf("%d\n", k);
32     return 0;
33 }
View Code
posted @ 2014-02-07 04:43  HaibaraAi  阅读(168)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3