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. Winter Storm Warning

    2019-01-02 11:22:33 ...WINTER STORM WARNING REMAINS IN EFFECT UNTIL 6 AM AKST TUESDAY... * WHAT...He ...

  2. BootStrap同时显示多个Modal解决方案

    使用BootStrap自带的Modal的时候,如果同时调用多个Modal,那么只能看到背景颜色加深但是看不见新的Modal页面. 问题主要是Modal的z-index有问题,重新计算z-index并赋 ...

  3. EL—表达式

    El的数据访问操作: 1:获取变量名(四大作用域中的变量?六大作用域?) 只能从这六个区域中拿数据!!! 2:获取对象的属性值 3:获取集合元素 4:执行表达式 1:获取变量名(四大作用域中的变量) ...

  4. SV中的Interface和Program

    Interface:SV中新定义的接口方式,用来简化接口连接,使用时注意在module或program之外定义interface,然后通过'include来添加进工程. interface  arb_ ...

  5. Repeater 控件使用总结

      关于Repeater控件使用的一些总结,希望能对将来有机会看到这篇日志的同事有所帮助.也是为了在自己开发有所遗忘的时候能够参考一下.前言:Repeater是一个迭代控件,什么是迭代控件呢?书本上的 ...

  6. 查看Tensorflow版本

    python -c 'import tensorflow as tf; print(tf.__version__)' # for Python 2 python3 -c 'import tensorf ...

  7. SQL: 左连接,右连接,内连接,左外连接,右外连接,完全连接

    例子: ---------------------- --------------------------- a表 id name b表 id job parent_id 1 张三           ...

  8. Javassist注解(Annotation)的使用:CXF WebService动态生成

    设计一个对接系统,通过动态模型的增删改触发业务系统相应服务的调用.模型增删改方法动态发布为WebService服务.WebService服务采用CXF发布,动态类生成采用Javassist.由于Web ...

  9. Python3 异常: name 'basestring' is not defined

    Python3 异常: name 'basestring' is not defined 问题分析: python3 里已经没有basestring 类型,用str代替了basestring : 解决 ...

  10. Unity3D之预设

      预设的两个特性: 1.重用性.可以使我们快速方便的创建大量的重复性资源.这种创建是通过预设的实例化Instance操作来完成的 在Hierarchy视图中将实例物理添加到Assests中,此时图标 ...