题目: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. 修正 phpcmsv9 VIP过期日期为1970

    打开 phpcms/modules/member/member.php 找到 $form_overdudate = form::date('info[overduedate]', date('Y-m- ...

  2. linux乱码问题:LANG变量的秘诀

    对于国内的Linux用户,经常烦恼的一个问题是:系统常常在需要显示中文的时候却显示成了乱码,而由于某些原因,需要英文界面的系统的时候,却苦于系统不能正常输入和显示中文.另外,由于大部分主要Linux发 ...

  3. The Best Rank (25)(排名算法)

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  4. Thinkphp C方法

    C方法是ThinkPHP用于设置.获取,以及保存配置参数的方法,使用频率较高. 了解C方法需要首先了解下ThinkPHP的配置,因为C方法的所有操作都是围绕配置相关的.ThinkPHP的配置文件采用P ...

  5. 最简单去Button回车事件

    描述: 有的时候,回车时,不想触发 页面上的保存按钮的事件. 有一种最简单的解决 方法: 一,把form增加一个不用的默认button <form id="form1" ru ...

  6. php+mysql分页类的入门实例

    php+mysql分页类的简单代码 时间:2016-02-25 06:16:26来源:网络 导读:php+mysql分页类的简单代码,二个php分页类代码,对商品进行分页展示,当前页面数,每个页面展示 ...

  7. 1050 棋盘染色 2 - Wikioi

    题目描述 Description 有一个5*N的棋盘,棋盘中的一些格子已经被染成了黑色,你的任务是对最少的格子染色,使得所有的黑色能连成一块. 输入描述 Input Description 第一行一个 ...

  8. SQL的集合运算符介绍

    最近学习了SQL SERVER方面的知识,毕竟做Web应用,少不了跟数据库打交道.学习的来源主要是<程序员的SQL金典>这本书. 今天介绍数据库里面的集合运算符,它是指匹配集合的每一个结果 ...

  9. leetcode2 Two Sum II – Input array is sorted

    Two Sum II – Input array is sorted whowhoha@outlook.com Question: Similar to Question [1. Two Sum], ...

  10. "Principles of Reactive Programming" 之 <Persistent Actor State>学习笔记

    这是<Pinciples of Reactive Programming>week6的最后一课. 为什么需要把actor的状态持久化? 如果actor没有状态,那么在任何实时,这个acto ...