Codeforces 388A - Fox and Box Accumulation
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的更多相关文章
- 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 ...
- codeforces A. Fox and Box Accumulation 解题报告
题目链接:http://codeforces.com/problemset/problem/388/A 题目意思:有 n 个 boxes,每个box 有相同的 size 和 weight,但是stre ...
- 388A Fox and Box Accumulation
一开始贪心策略想错了! #include<cstdio> #include<algorithm> using namespace std; ]; int main() { in ...
- 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 ...
- 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 ...
- Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation(贪心)
题目:http://codeforces.com/contest/389/problem/C 题意:给n个箱子,给n个箱子所能承受的重量,每个箱子的重量为1: 很简单的贪心,比赛的时候没想出来.... ...
- A. Fox and Box Accumulation
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- cf C. Fox and Box Accumulation
题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...
- [codeforces 241]C. Mirror Box
[codeforces 241]C. Mirror Box 试题描述 Mirror Box is a name of a popular game in the Iranian National Am ...
随机推荐
- Linux系统——MySQL基础(一)
# 数据库 ## 数据库简单的分类:(1)关系型数据库:MySQL和Oracle.Postgresql(2)非关系型数据库:Memcached和Redis(3)消息队列中间件(4)搜索引擎数据库:El ...
- c#中ref和out使用及区别
在c#中,使用方法获得返回值时,只能获取一个返回值.当使用ref和out关键字后,可以获取多个返回值. MSDN对ref和out关键字的说明如下: ref 关键字: 使参数按引用传递.其效果是,当控制 ...
- Java一元操作符++详解
废话不多说,直接上代码. package com.coshaho.learn; /** * * OperatorLearn.java Create on 2016-11-13 下午8:38:15 * ...
- Python 运算符与基本数据类型
一.运算符 1.算数运算: 2.比较运算: 3.赋值运算: 4.逻辑运算: 5.成员运算: 二.基本数据类型 1.空(None) 表示该值是一个空对象,空值是Python里一个特殊的值,用None表示 ...
- Oracle查询session连接数和inactive以及 概要文件IDLE_TIME限制用户最大空闲连接时间
-----############oracle会话和进程################----------------查询会话总数select count(*) from v$session;--查 ...
- LabVIEW如何方便地调用DLL文件
转自:http://bbs.elecfans.com/jishu_469502_1_1.html LabVIEW调用DLL文件 LabVIEW支持通过调用DLL文件的方式与其它编程语言混合使用.比 ...
- Python3.x:import urllib2报错解决方案
Python:import urllib2报错解决方案 python2和3有些不一样: python2:输出为print 'hello world' python3:输出为print('hello w ...
- 关于mysql连接抛出10038错误问题
今天用Navicat Premium连接windows server 2003 mysql的时候, 抛出10038问题, 这种问题之前在rhel也出现过一次, 就是防火墙不允许连接kill掉了这个请求 ...
- Python3基础 os.path.dirname 对路径字符串进行处理 返回所在文件夹的路径
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Linux内核分析--系统调用【转】
本文转载自:http://www.cnblogs.com/paperfish/p/5308505.html 前言:以下笔记除了一些讲解视频中的概念记录,图示.图示中的补充文字.总结.分析.小结部分均是 ...