题意:输入一个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的更多相关文章

  1. Codeforces 388A - Fox and Box Accumulation

    388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. A. Fox and Box Accumulation

    time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...

  6. codeforces A. Fox and Box Accumulation 解题报告

    题目链接:http://codeforces.com/problemset/problem/388/A 题目意思:有 n 个 boxes,每个box 有相同的 size 和 weight,但是stre ...

  7. Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)

    题目:http://codeforces.com/contest/389/problem/C 题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1: 很简单的贪心,比赛的时候没想出来.... ...

  8. 388A Fox and Box Accumulation

    一开始贪心策略想错了! #include<cstdio> #include<algorithm> using namespace std; ]; int main() { in ...

  9. CF 371B Fox Dividing Cheese[数论]

    B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...

随机推荐

  1. Hibernate的游离态与持久态转换

    在Hibernate中,一个PO可能经过长时间的操作,session已过时关闭,此时PO已经是一个游离态的对象,这时要转换为持久战态,有下面几种方法: 1.session.saveOrUpdate(o ...

  2. hive 配置文件以及join中null值的处理

    一.Hive的參数设置 1.  三种设定方式:配置文件 ·   用户自己定义配置文件:$HIVE_CONF_DIR/hive-site.xml ·   默认配置文件:$HIVE_CONF_DIR/hi ...

  3. MySQL Error Handling in Stored Procedures---转载

    This tutorial shows you how to use MySQL handler to handle exceptions or errors encountered in store ...

  4. Struts2 result type

    Struts2支持的不同类型的返回结果为: type name 说明 dispatcher 缺省类型,用来转向页面,通常处理JSP chain 转向另一个action,用来处理Action链 redi ...

  5. 第二篇:python高级之装饰器

    python高级之装饰器   python高级之装饰器 本节内容 高阶函数 嵌套函数及闭包 装饰器 装饰器带参数 装饰器的嵌套 functools.wraps模块 递归函数被装饰 1.高阶函数 高阶函 ...

  6. poj 1849 Two

    /*poj 1849 two 思考一下会发现 就是求直径 直径上的中点就是两个人分开的地方(不再有交集)*/ #include<cstdio> #define maxn 100010 us ...

  7. 将MVC中的Controllers、Model和View分别放到单独的项目中

    Model: 新建-项目-Windows-类库 MVCTest.Model Controller:新建-项目-Windows-控制台应用程序 MVCTest.Bussiness Views:新建-项目 ...

  8. mysql - 编码

    show variables like 'character%'; 通过以上命令可以查询编码情况, 不过,在安装的时候,建议选择‘gbk’这类中文编码, 如果选择的是utf8,则在处理的过程中需要进行 ...

  9. Encapsulation.

    Access control is often referred to as implementation hiding. Wrapping data and methods within class ...

  10. Mysql在php5中的应用

    1.PHP与mysql建立连接 php.ini加载mysql组件 extension=php_mysql.dll 前的;去掉 extension_dir=””路径是否正确 PHP连接mysql函数 m ...