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. HDU 1700 Points on Cycle (几何 向量旋转)

    http://acm.hdu.edu.cn/showproblem.php?pid=1700 题目大意: 二维平面,一个圆的圆心在原点上.给定圆上的一点A,求另外两点B,C,B.C在圆上,并且三角形A ...

  2. 【Java】系统漏洞:关于用户登录后操作的注意事项

    项目背景: SpringMVC + Mybatis  + MySql数据库(javaWeb项目开发) 相关模块:登录,个人详细信息修改,订单详情查询 相关漏洞介绍: 1.登录的验证码:登录的验证码一定 ...

  3. winfrom 下 listbox 选项添加value

    public struct MyItem { public string Name; public string Tag; public override string ToString() { re ...

  4. Git本地仓库与远程github同步的时候提示fatal: remote origin already exists 错误解决办法

    Git本地仓库与远程github同步的时候提示fatal: remote origin already exists 错误解决办法 1.git在本地的电脑创建了仓库,要远程同步github的仓库.使用 ...

  5. ajax 拦截器设置请求头

    使用vue-resource时,往headers里添加token后,post方法会自动变成options? Vue.http.interceptors.push(function(request, n ...

  6. 怎么解决深入学习PHP的瓶颈

    PHP给学习者的感觉是:初学的时候很容易,但是学了2-3年,就深刻感觉遇到了瓶颈,很难深入,放弃又可惜.所谓"鸡肋,食之无味弃之可惜"的感觉很是贴切. 经常会有这种感觉:不学,看似 ...

  7. OpenCV相关网站推荐(Informative websites related to OpenCV)

    原文来自:http://answers.opencv.org/question/69691/informative-websites-related-to-opencv/ i think it wil ...

  8. Matchvs 使用记录

    Matchvs Matchvs视频教程. https://doc.matchvs.com/VideoTutorials/videogs matchvs下载资源. http://www.matchvs. ...

  9. [JVM] - 一份<自己动手写Java虚拟机>的测试版

    go语言下载 配置GOROOT(一般是自动的),配置GOPATH(如果想自己改的话) 参照<自己动手写Java虚拟机> > 第一章 指令集和解释器 生成了ch01.exe文件 这里还 ...

  10. session的理解和使用

    Session的使用与Session的生命周期 1.HttpSession的方法 Object getAttribute(String); Enumeration<String> getA ...