题意:输入一个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. [io PWA] Great libraries and tools for great Progressive Web Apps

    sw-toolbox: Github It provides a cononical implementation of all the runtime caching strategies that ...

  2. cs模式与bs模式

     关于CS(Client-Server)模式和BS(Browser-Server)模式的水很深,盆地自己也认为对此了解不够透彻,但作为手机客户端设计,如果不对CS.BS做一定程度的了解,是很容易出现一 ...

  3. Qt 学习之路:自定义事件

    尽管 Qt 已经提供了很多事件,但对于更加千变万化的需求来说,有限的事件都是不够的.例如,我要支持一种新的设备,这个设备提供一种崭新的交互方式,那么,这种事件如何处理呢?所以,允许创建自己的事件 类型 ...

  4. Android群英传》读书笔记 (4) 第八章 Activity和Activity调用栈分析 + 第九章 系统信息与安全机制 + 第十章 性能优化

    第八章 Activity和Activity调用栈分析 1.Activity生命周期理解生命周期就是两张图:第一张图是回字型的生命周期图第二张图是金字塔型的生命周期图 注意点(1)从stopped状态重 ...

  5. Java基础知识强化之集合框架笔记29:使用LinkedList实现栈数据结构的集合代码(面试题)

    1. 请用LinkedList模拟栈数据结构的集合,并测试:  题目的意思是:     你自己的定义一个集合类,在这个集合类内部可以使用LinkedList模拟,使用LinkedList功能方法封装成 ...

  6. json、xml ---- 数据格式生成类

    自己写的一个生成json/xml 格式数据的类,可用于api数据传输: <?php class Response{ /** *生成指定数据格式 *@param intval $code 状态码 ...

  7. php 多维数组转换

    把字符类型转换成时间类型的,先用foreach遍历出来时间,在通过时间函数转换成时间格式; 例子: <?phpecho "<pre>";$lsrfield = a ...

  8. git语言

    安装完成后,需要进一步设置用户名和email.因为git是分布式版本控制工具,因此需要每台开发机自报家门. $ git config --global user.name "Your Nam ...

  9. JAVA DATE解析(时间戳解析为固定格式)

    public class SimpleDateFormat extends DateFormat SimpleDateFormat 是一个以国别敏感的方式格式化和分析数据的具体类. 它允许格式化 (d ...

  10. ado.net与各种orm操作数据方式的比较

    ADO.NET与ORM的比较(1):ADO.NET实现CRUD http://zhoufoxcn.blog.51cto.com/792419/283952 ADO.NET与ORM的比较(2):NHib ...