Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)
题目: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(贪心)的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #228 (Div. 1) 388B Fox and Minimal path
链接:http://codeforces.com/problemset/problem/388/B [题意] 给出一个整数K,构造出刚好含有K条从1到2的最短路的图. [分析] 由于是要自己构造图,当 ...
- Codeforces Round #228 (Div. 2) B. Fox and Cross
#include <iostream> #include <string> #include <vector> #include <algorithm> ...
- Codeforces Round #228 (Div. 2) A. Fox and Number Game
#include <iostream> #include <algorithm> #include <vector> #include <numeric> ...
- Codeforces Round #228 (Div. 2)
做codeforces以来题目最水的一次 A题: Fox and Number Game 题意:就是用一堆数字来回减,直到减到最小值为止,再把所有最小值加,求这个值 sol: 简单数论题目,直接求所有 ...
- 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 ...
随机推荐
- Sublime text2 常用插件集锦
No.01 – EmmetEmmet 是一个前端开发的利器,其前身是Zen Coding.它让编写 HTML 代码变得简单.Emmet 的基本用法是:输入简写形式,然后按 Tab 键.关于 Emmet ...
- 好用的ssh工具oh-my-zsh / iterm2
The manual way 1. Clone the repository: git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh- ...
- 用CSS和第三方库来提升图片浏览体验
你是否关注过浏览.点击图片这个微妙的过程,不同的图片展现.交互方式各带来什么样的观感?本文聚焦于图片浏览这个过程以及如何使用CSS3和第三方库来提升体验. 先看下Pinterest.Flickr等时下 ...
- js判断选择时间不能小于当前时间的代码
判断选择时间不能小于当前时间的方法有很多,在本文为大家详细介绍下使用js是如何实现的,感兴趣的朋友可以尝试操作下 复制代码代码如下: var controldate; function checkD ...
- phpcms v9 打开网站特别慢 增加数据库缓存方法
SET GLOBAL QUERY_CACHE_SIZE=80000000; 设置好查询缓存的大小就行了.比如设置个20MB.SET GLOBAL QUERY_CACHE_SIZE=20000000; ...
- Win7 64bit 成功安装ArcView3.X
本人参考 链接 已在Win7 64Bit 笔记本上成功安装ArcView3.3,于是记录以下心得。 Win7 64Bit安装不了ArcView3.X的原因在于: 1,ArcView3.X属于16Bit ...
- ORA-27102: out of memory并伴随OSD-00031的处理
刚才客户电话过来说有个数据库起不来了,开发商搞了好久搞不掂,得要让我们去帮忙看看.过去到现场,发现数据库无法打开,连nomount模式都不可以.报错的内容大致如下: ORA-27102: out of ...
- myEclipse中的web项目直接引入到eclipse中运行
首先打开项目属性(Properties),如果动态web项目被作为普通java项目引进去,需要首先修改为web项目,如下图: 确定后即可在eclipse中看到转换为了动态的web项目,然后继续属性(P ...
- Mac下安装Redis图解教程
去redis官网(http://redis.io/download)自行下载安装包解压缩到本地文件夹,比如放在Mac应用程序文件夹(/Applications/),在终端进入redis文件夹. 需要进 ...
- bnuoj 4225 杨辉三角形(规律)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4225 [题意]: 给定任意杨辉三角的行数n,请输出杨辉三角中前n行中总共有多少偶数. [题解]: 找 ...