题目: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. Delphi通过Map文件查找内存地址出错代码所在行

    一 什么是MAP文件 什么是 MAP 文件?简单地讲, MAP 文件是程序的全局符号.源文件和代码行号信息的唯一的文本表示方法,它可以在任何地方.任何时候使用,不需要有额外的程序进行支持.而且,这是唯 ...

  2. 电网SVG简介

    目 录1.        范围        12.        规范性引用文件        13.        缩略语        14.        本标准涉及的图形交换特征      ...

  3. onclick控制元素显示与隐藏时,点击第一次无反应的原因

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  4. OOP三类继承的区别

    OOP继承的区别提纲: 1. 普通类继承,并非一定要重写父类方法.2. 抽象类继承,如果子类也是一个抽象类,并不要求一定重写父类方法.如果子类不是抽象类,则要求子类一定要实现父类中的抽象方法.3. 接 ...

  5. OFBiz进阶之HelloWorld(五)创建新实体

    参考文档 https://cwiki.apache.org/confluence/display/OFBIZ/OFBiz+Tutorial+-+A+Beginners+Development+Guid ...

  6. .net google calendar

    https://developers.google.com/gdata/client-cs http://www.codeproject.com/Articles/64474/How-to-Read- ...

  7. JavaScript中常谈的对象

    为浏览器编写代码时,总少不了window对象 window对象表示JavaScript程序的全局环境 同时 也表示应用的主窗口 到处都是对象 window对象 常用的属性和方法介绍 location ...

  8. C#学习笔记(三)

    1.我们在Main()函数中,调用Test()函数,我们管Main()函数称之为调用者,管Test()函数称之为被调用者.如果被调用者想要得到调用者的值:1).传递参数.2).使用静态字段来模拟全局变 ...

  9. <span> <div> 局部 keydown ,keyup事件。页面部分div $(document) 无效,可能焦点,添加焦点。

    前天改一个bug, js 实现的一个 面板拖拉,左右各两个列表,中间面板画线连接,页面左侧列表选中后,key 事件无效.右侧选中确有效,很奇怪,查看源码,左侧选中后,$(document).on(&q ...

  10. js检测浏览器版本代码,兼容ie11

    原文:http://blog.csdn.net/tenkin/article/details/11640165 <script type="text/javascript"& ...