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. 定时器事件QtimerEvent 随机数 qrand Qtimer定时器

    QTimerEvent类:定时器事件.QObject的子类都可使用  int QObject::startTimer(int interval)[参数:毫秒][返回值:定时器整型编号]来开启一个定时器 ...

  2. 改变 select下拉框 样式

    select{ outline: none; text-indent: 10px; height: 45px; line-height: 45px; width: 100%; border:1px s ...

  3. zw版【转发·台湾nvp系列Delphi例程】HALCON MirrorImage

    zw版[转发·台湾nvp系列Delphi例程]HALCON MirrorImage procedure TForm1.Button1Click(Sender: TObject);var img, im ...

  4. HDU 4770

    这题说的是一在一个N*M的房间内,然后有些房间不能被灯光照亮,有一个灯可以转动方向,其他的灯只能在固定一个方向上,因为数据比较小,所以比较水,直接暴力的进行枚举就好了,但是还是 wa了很久,原因没认真 ...

  5. VS添加节点

    很喜欢添加节点来减少代码的长度,方便阅读:VS快捷键和相关设置

  6. Python: yield, python 实现tail -f

    def CreateGenerator(file): with open(file,'r') as t: t.seek(0,2) while True: line=t.readline() if no ...

  7. 2018-2019-2 20165209 《网络对抗技术》Exp7: 网络欺诈防范

    2018-2019-2 20165209 <网络对抗技术>Exp7: 网络欺诈防范 1 基础问题回答和实验内容 1.1基础问题回答 (1)通常在什么场景下容易受到DNS spoof攻击. ...

  8. Open-Falcon

    A Distributed and High-Performance Monitoring System Scalability Scalable monitoring system is neces ...

  9. jquery中的load方法加载页面无法缓存问题

    在A页面中调用JQuery中的load方法,加载另一个B页面,B页面中的样式文件和JS文件无法从浏览器缓存中获取,每次都是实时获取.这是因为B页面的HTML经load方法处理后,会为每个样式和JS文件 ...

  10. 分布式系统一致性算法Raft

    Raft 算法也是一种少数服从多数的算法,在任何时候一个服务器可以扮演以下角色之一:Leader:负责 Client 交互 和 log 复制,同一时刻系统中最多存在一个Follower:被动响应请求 ...