题目: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. JavaScript的语法要点 3 - Calling Context

    上一篇讲了JavaScript的Scope Chain - 每一个函数都有一个scope chain与之关联,scope chain上有第一个对象维护着本地变量作为其属性.另外我们在JavaScrip ...

  2. PHP网页的工作原理

    网络基本概念 IP地址 唯一标识网络上的主机或设备. IP地址是由四段8位二进制构成,中间用小数点隔开.如:192.168.18.70 每一段取值0-255的十进制. 特殊的IP地址:127.0.0. ...

  3. ISO-9126 软件质量模型

    摘要 在软件开发过程中,软件的质量是一个重要的因素,而软件体系结构在整个过程中显得尤为重要.软件的质量需求是在开发初期的非功能性需求,对软件的体系结构影响很大.但是并不意味着一味的追求质量,必须在效率 ...

  4. install window7

    install window7 http://www.zhujixc.com/win7home/http://jingyan.baidu.com/album/5bbb5a1b3e301713eba17 ...

  5. MVC视图引擎

    1.视图引擎:把视图解析成浏览器可执行的html代码 2.aspx视图: <%=表达式%>: <% C#代码段 %>: 3.razor视图: @(表达式):@ViewData[ ...

  6. linux内核分析之进程地址空间管理

    1.struct task_struct 进程内核栈是操作系统为管理每一个进程而分配的一个4k或者8k内存大小的一片内存区域,里面存放了一个进程的所有信息,它能够完整的描述一个正在执行的程序:它打开的 ...

  7. Maven 解决JAR包冲突

    在JAR 冲突的情况下, 利用Eclipse方式解决JAR包冲突时比较方便简洁的,步骤如下 1. 在Eclipse 中打开pom.xml , 选择  “Dependency  Hierarchy” 2 ...

  8. PAT-乙级-1029. 旧键盘(20)

    1029. 旧键盘(20) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 旧键盘上坏了几个键,于是在敲一段文字的 ...

  9. Window8 进不了PE如何设置BIOS

    如题,如今进入Win8时代,很多新出的机器都自带了WIN8.但是童鞋们想进PE进行操作的时候,发现进不了. 更改BIOS以下2处设置,即可使用第三方引导安装系统:Boot->Launch CSM ...

  10. 荣誉,还是苦逼?| 也议全栈工程师和DevOps

    引言 全栈工程师(本文称「全栈」开发者)和 DevOps 无疑是近期最火的词汇,无论是国外还是国内.而且火爆程度远超于想象. 全栈和 DevOps,究竟是我们的新职业方向,还是仅仅创业公司老板的心头所 ...