cf C. Fox and Box Accumulation
题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数。
思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有找到,结果加1;最后就是答案。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int n;
int x[];
int num[];
int dp[][];
bool vis[]; int main()
{
while(scanf("%d",&n)!=EOF)
{
for(int i=; i<n; i++)
{
scanf("%d",&x[i]);
}
memset(vis,false,sizeof(vis));
sort(x,x+n);
int ans=;
for(int i=; i<n; i++)
{
num[i]=;
}
for(int i=; i<n; i++)
{
int m=num[i];
bool flag=false;
for(int j=i; j<n; j++)
{
if(x[j]>=m&&num[j]==&&j!=i)
{
flag=true;
num[j]+=m;
break;
}
}
if(!flag) ans++;
}
printf("%d\n",ans);
}
return ;
}
cf C. Fox and Box Accumulation的更多相关文章
- Codeforces 388A - Fox and Box Accumulation
388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...
- 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 388A Fox and Box Accumulation (模拟)
A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...
- 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 ...
- A. Fox and Box Accumulation
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- codeforces A. Fox and Box Accumulation 解题报告
题目链接:http://codeforces.com/problemset/problem/388/A 题目意思:有 n 个 boxes,每个box 有相同的 size 和 weight,但是stre ...
- Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)
题目:http://codeforces.com/contest/389/problem/C 题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1: 很简单的贪心,比赛的时候没想出来.... ...
- 388A Fox and Box Accumulation
一开始贪心策略想错了! #include<cstdio> #include<algorithm> using namespace std; ]; int main() { in ...
- CF 371B Fox Dividing Cheese[数论]
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- struts 2学习笔记—浅谈struts的线程安全
Sruts 2工作流程: Struts 1中所有的Action都只有一个实例,该Action实例会被反复使用.通过上面Struts 2 的工作流程的红色字体部分我们可以清楚看到Struts 2中每个A ...
- 吧php脚本打包成 exe程序
操作方法 :FQ哦 https://www.youtube.com/watch?v=UQ3zxqh1YXY 有很多方法可以实现 找了个外国的哥们制作的工具 可以吧文件生成很简单的一个独立EXE文件 下 ...
- PHP读取文件头(2字节)判断文件类型(转)
看到此标题或许你会说是否是多此一举,直接判断扩展名不就知道文件类型了吗,但是扩展名很容易伪造,这样就绕过了判断.大部分的文件都会将一个特殊的数字或字符存放在文件的特定位置里(开始处的2个字节) /** ...
- 亲测PHP环境
一.安装Apache2.2.22→1.下载软件,点安装 2.填写dengguoxing.com www.dengguoxing.com(暂时不知道什么用)3.custom 个性化安装 更改路径即可 ...
- Eclipse配置使用web.xml
为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/SJQ. http://www.cnblogs.com/shijiaqi1066/p/3792664.html ...
- int? 参数是这个的时候 是可以传入null的 而int的就不行
such as pager.CurrentPageIndex = (page != null ? (int)page : 1);
- 15、SQL Server 触发器
SQL Server 触发器 触发器是一种特殊的存储过程,只有当试图用数据操作语言DML来修改数据时才会触发,DML包含对视图和表的增.删.改. 触发器分为DML触发器和DDL触发器,其中DML触发器 ...
- js自定义方法名
自定义方法名: <script language="javascript" type="text/javascript">window.onload ...
- 表达式:使用API创建表达式树(6)
一.ConstantExpression:表示具有常量值的表达式.因为表达式应用过程中,参数据多是 Expressions 类型,算是对常量值的一种包装吧. ConstantExpression使用比 ...
- 美好头标ToolBar
ActionBar我相信是每一位合格的程序员都用过的组件,也是每一个程序员都会抱怨的组件,因为他不能实现复杂的自定义.为此Google推出了比ActionBar更为美好的组件ToolBar. 本文重点 ...