题意:输入一个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. Memo打印

        加入Printers单元, ;   Left ;    y ;; do      begin        Printer.Canvas.TextOut(x,y,Memo1.Lines[i]) ...

  2. Python读写文件需要注意的地方 2015-03-31 23:19 69人阅读 评论(0) 收藏

    <span style="font-family: 'Microsoft YaHei'; background-color: rgb(255, 255, 255);"> ...

  3. I/O体系结构和设备驱动程序

    http://blog.csdn.net/kafeiflynn/article/category/789844

  4. [转] 学习使用:before和:after伪元素

    http://www.w3cplus.com/css3/learning-to-use-the-before-and-after-pseudo-elements-in-css.html 如果你一直密切 ...

  5. 如何判断Fragment是否对用户可见

    背景 最近在开发中遇到了一个问题.我们的app需要统计用户的页面路径,也就是用户使用各个页面的情况.这就需要在不同的页面跳入和跳出时记录下来.但是我们的app主要是由Fragment构成的.而在不同的 ...

  6. 高效 css 整理

    避免通用规则 请确保规则不以通用类型作为结束! 不要用标签名或 classes 来限制 ID 规则 如果规则的关键选择器为 ID 选择器,则没有必要为规则增加标签名.因为 ID 是唯一的,增加标签只会 ...

  7. Maven学习总结——聚合与继承

    一.聚合 如果我们想一次构建多个项目模块,那我们就需要对多个项目模块进行聚合 1.1.聚合配置代码 1 <modules> 2 <module>模块一</module&g ...

  8. 第六篇:python高级之网络编程

    python高级之网络编程   python高级之网络编程 本节内容 网络通信概念 socket编程 socket模块一些方法 聊天socket实现 远程执行命令及上传文件 socketserver及 ...

  9. 各种语言HMAC SHA256实现

    语言包含: Javascript ,PHP,Java,Groovy,C#,Objective C,Go,Ruby,Python,Perl,Dart,Swift,Rust,Powershell. Jav ...

  10. ASP。net中如何在一个按钮click事件中调用另一个按钮的click事件

    方法一: 直接指定 事件<asp:Button ID="btn1" runat="server" Text="按钮1" onclick ...