388A - Fox and Box Accumulation

思路

从小到大贪心模拟。

代码

#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=;
int a[N];
bool vis[N]={false};
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
int ma=;
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
}
int ans=,tot=n;
sort(a,a+n);
while(tot)
{
int cnt=;
for(int i=;i<n;i++)
{
if(!vis[i]&&cnt<=a[i])
{
vis[i]=true;
cnt++;
tot--;
}
}
ans++;
}
cout<<ans<<endl;
return ;
}
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int N=;
int a[N];
int Hash[N]={};
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
int ma=;
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
ma=max(ma,a[i]);
Hash[a[i]]++;
}
int ans=;
while(n)
{
int cnt=;
for(int i=;i<=ma;i++)
{
while(Hash[i]&&i>=cnt)
{
Hash[i]--;
cnt++;
n--;
}
}
ans++;
}
cout<<ans<<endl;
return ;
}

Codeforces 388A - Fox and Box Accumulation的更多相关文章

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

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

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

  3. 388A Fox and Box Accumulation

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

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

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

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

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

  7. A. Fox and Box Accumulation

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

  8. cf C. Fox and Box Accumulation

    题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...

  9. [codeforces 241]C. Mirror Box

    [codeforces 241]C. Mirror Box 试题描述 Mirror Box is a name of a popular game in the Iranian National Am ...

随机推荐

  1. java反射之根据全类名创建对象

    现在的需求是根据类的全名.来创建对象 package 中介者设计模式; import java.util.Date; public class CreateObject { public static ...

  2. 总结C#获取当前路径的7种方法

    C#获取当前路径的方法如下: 1. System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName -获取模块的完整路径. 2. ...

  3. mysql进程文件

  4. 将Pytorch模型从CPU转换成GPU

    1. 如何进行迁移 对模型和相应的数据进行.cuda()处理.通过这种方式,我们就可以将内存中的数据复制到GPU的显存中去.从而可以通过GPU来进行运算了. 1.1 判定使用GPU 下载了对应的GPU ...

  5. 深入理解 Java 内存模型(一)- 内存模型介绍

    深入理解 Java 内存模型(一)- 内存模型介绍 深入理解 Java 内存模型(二)- happens-before 规则 深入理解 Java 内存模型(三)- volatile 语义 深入理解 J ...

  6. 谷歌插件--Advanced REST client

    早上在测试调用服务去获取数据的时候,因为自己的单元测试不是很熟悉,问了同事,同事给我介绍了一个插件Advanced REST client,这个可以在谷歌的“扩展与应用”中找打,使用 安装之后会提示要 ...

  7. Hive 常用函数汇总

    Hive内部提供了很多函数给开发者使用,包括数学函数,类型转换函数,条件函数,字符函数,聚合函数,表生成函数等等,这些函数都统称为内置函数. 目录 数学函数 集合函数 类型转换函数 日期函数 条件函数 ...

  8. windows下nodejs express安装及入门网站,视频资料,开源项目介绍

    windows下nodejs express安装及入门网站,视频资料,开源项目介绍,pm2,supervisor,npm,Pomelo,Grunt安装使用注意事项等总结 第一步:下载安装文件下载地址: ...

  9. python3.4学习笔记(七) 学习网站博客推荐

    python3.4学习笔记(七) 学习网站博客推荐 深入 Python 3http://sebug.net/paper/books/dive-into-python3/<深入 Python 3& ...

  10. 前端路由以及浏览器回退,hash & history & location

    一.前言 其实不止一次想监听浏览器的回退方法,比如 在 list.html 页滚动加载了几页列表,点到 detail.html 看详情,反回来时又得重新加载几页 H5 有背景音乐的,跳页就得重新放,体 ...