题目:http://codeforces.com/contest/389/problem/C

题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1;

很简单的贪心,比赛的时候没想出来。、、、、、

先从小到大排一下序,然后从最上层向下找,只要能承受住重量就行。而且因为已经排序了找的都是尽量小的。。。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std; int main()
{
int n,a[],f[],sum,x;
int i,j;
while(cin>>n)
{
sum=;
for(i=; i<n; i++)
cin>>a[i]; sort(a,a+n);
memset(f,,sizeof(f));
for(j=; j<n; j++)
{
x=;
for(i=; i<n; i++)
{
if(a[i]>=x&&f[i]==)
{
x++;
f[i]=;
}
}
if(x==)
break;
sum++;
}
printf("%d\n",sum);
}
return ;
}

Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)的更多相关文章

  1. 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 ...

  2. 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 ...

  3. Codeforces Round #228 (Div. 1) C. Fox and Card Game 博弈

    C. Fox and Card Game 题目连接: http://codeforces.com/contest/388/problem/C Description Fox Ciel is playi ...

  4. Codeforces Round #228 (Div. 1) B. Fox and Minimal path 构造

    B. Fox and Minimal path 题目连接: http://codeforces.com/contest/388/problem/B Description Fox Ciel wants ...

  5. Codeforces Round #228 (Div. 1) 388B Fox and Minimal path

    链接:http://codeforces.com/problemset/problem/388/B [题意] 给出一个整数K,构造出刚好含有K条从1到2的最短路的图. [分析] 由于是要自己构造图,当 ...

  6. Codeforces Round #228 (Div. 2) B. Fox and Cross

    #include <iostream> #include <string> #include <vector> #include <algorithm> ...

  7. Codeforces Round #228 (Div. 2) A. Fox and Number Game

    #include <iostream> #include <algorithm> #include <vector> #include <numeric> ...

  8. Codeforces Round #228 (Div. 2)

    做codeforces以来题目最水的一次 A题: Fox and Number Game 题意:就是用一堆数字来回减,直到减到最小值为止,再把所有最小值加,求这个值 sol: 简单数论题目,直接求所有 ...

  9. 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 ...

随机推荐

  1. laravel扩展图片处理Intervention Image

    github地址:https://github.com/Intervention/image

  2. 如何实现phpcms v9_4X版本tag的伪静态?

    这两个月来写的文章越来越少了,不是懒,因为太忙了--为客户赶做网站.因为客户指定要使用phpcms v9,还要求使用phpcms v9_42版本实现tag伪静态,在接手的时候phpcms v9_42是 ...

  3. CLR via C# 异常管理读书笔记

    1. 设计异常类型层次结构应该浅而宽 2. 注意使用finally块清理资源 3. 不要什么都捕捉 4.得体地从异常中恢复 5.发生不可恢复的异常时回滚部分完成的操作-维持状态 6.隐藏实现细节来维系 ...

  4. 关于hadoop2.4.2版本学习时遇到的问题

    问题一:namenode启动失败 描述:在初始化后hadoop后,发现datanode启动失败,namenode则可以正常启动,如果把用户换成root权限,再次启动时,则namenode和datano ...

  5. 拓展:return和print的使用时机

    拓展:return和print的使用时机  一直纠结函数里的return用法.以下内容摘自百度知道..def 是用来定义函数的一个关键字,只有在函数的定义时用到他.Python 函数定义的语法:def ...

  6. ofbiz进阶之实体引擎配置文件

    The Open For Business Project: Entity Engine Configuration Guide 原文链接:http://ofbiz.apache.org/docs/e ...

  7. PostgreSQL+PostGIS的使用 函数清单

    一. PostgreSQL与PostGIS的关系 PostgreSQL 是世界上技术最先进的开源数据库,其前身是1977年一个源于Berkeley名为Ingres的非关系型数据库,其项目领导人为Mic ...

  8. HTML 菜单 a 标签设置样式

    html: "<div style='font-weight:800;color:red'> <a href='javascript:void(0)'style='colo ...

  9. iOS中touches事件,addtarget ...action和GestureRecognizer详解

    刚学完uiview,uicontrol类,许多人知道 touchesBegain,touchesMoved,touchesEnd,GestureRecognizer的用途,但仔细考虑这些事件之间的关系 ...

  10. Telerik_2012_Q3 RadGrid 汉化

    ChineseRadGridLocalizationProvider.cs using System; using System.Collections.Generic; using System.L ...