华中农业大学第五届程序设计大赛网络同步赛-K
K.Deadline
There are N bugs to be repaired and some engineers whose abilities are roughly equal. And an engineer can repair a bug per day. Each bug has a deadline A[i].
Question: How many engineers can repair all bugs before those deadlines at least? 1<=n<= 1e6. 1<=a[i] <=1e9
Input
Description There are multiply test cases. In each case, the first line is an integer N , indicates the number of bugs. The next line is n integers indicates the deadlines of those bugs.
Output
Description There are one number indicates the answer to the question in a line for each case.
Input
4 1 2 3 4
Output
1
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; const int N = ;
int a, book[N], day[N]; int main()
{
int n;
while(scanf("%d", &n)!=EOF)
{
int len = ;
memset(book, , sizeof(book));
memset(day, , sizeof(day));
for(int i = ; i < n; i++)
{
scanf("%d", &a);
if(a <= n)
book[a]++;
if(a < n && a > len)len = a;
}
int ans = ;
for(int i = ; i <= len; i++)
{
while(book[i]){
bool fg = false;
for(int j = ; j <= ans; j++){
if(day[j] < i){
book[i]--;
day[j]++;
fg = true;
break;
}
}
if(!fg){
ans++;
day[ans]++;
book[i]--;
}
}
}
printf("%d\n", ans);
} return ;
}
华中农业大学第五届程序设计大赛网络同步赛-K的更多相关文章
- 华中农业大学第五届程序设计大赛网络同步赛-L
L.Happiness Chicken brother is very happy today, because he attained N pieces of biscuits whose tast ...
- 华中农业大学第五届程序设计大赛网络同步赛-G
G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...
- 华中农业大学第五届程序设计大赛网络同步赛-D
Problem D: GCD Time Limit: 1 Sec Memory Limit: 1280 MBSubmit: 179 Solved: 25[Submit][Status][Web B ...
- 华中农业大学第五届程序设计大赛网络同步赛-A
Problem A: Little Red Riding Hood Time Limit: 1 Sec Memory Limit: 1280 MBSubmit: 860 Solved: 133[S ...
- [HZAU]华中农业大学第四届程序设计大赛网络同步赛
听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...
- (hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C
题目链接:http://acm.hzau.edu.cn/problem.php?id=18 题意是给你两个长度为n的数组,a数组相当于1到n的物品的数量,b数组相当于物品价值,而真正的价值表示是b[i ...
- 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列
Problem G: Array C Time Limit: 1 Sec Memory Limit: 128 MB Description Giving two integers and and ...
- 华中农业大学第四届程序设计大赛网络同步赛 J
Problem J: Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1766 Solved: 299[Subm ...
- 华中农业大学第四届程序设计大赛网络同步赛 I
Problem I: Catching Dogs Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1130 Solved: 292[Submit][St ...
随机推荐
- 前端基础-html 介绍和head标签 ( 1 )
主要内容 web标准 浏览器介绍 开发工具介绍 HTML介绍 HTML颜色介绍 HTML规范 HTML结构详解 写在前面: 前端 后端 C(client) S ...
- 容器监控:cadvisor+influxdb+grafana
cAdvisor:Google开源的工具,用于监控Docker主机和容器系统资源,通过图形页面实时显示数据,但不存储:它通过宿主机/proc./sys./var/lib/docker等目录下文件获取宿 ...
- .net core Error -4090 EADDRNOTAVAIL address not available”
问题原因:IP地址错误或者网络未开
- javascript数据结构与算法--高级排序算法(快速排序法,希尔排序法)
javascript数据结构与算法--高级排序算法(快速排序法,希尔排序法) 一.快速排序算法 /* * 这个函数首先检查数组的长度是否为0.如果是,那么这个数组就不需要任何排序,函数直接返回. * ...
- 【原创】SQL Server 性能调优读书笔记
CPU 100%: 有时可能是硬盘性能不足,或者内存容量不够,让CPU一直忙于I/O. 导致性能问题的一些因素: 用户习惯:在运行尖峰时刻做一些不必做但消耗资源的事情,如之行数据库完整备份,如在服务器 ...
- 没啥事用C语言写一个Trie tree玩玩,支持中英文,用g++编译通过
#include <cstdio> #include <cstdlib> #include <vector> #define ALPHABETS 2600000 # ...
- 监督学习——决策树理论与实践(下):回归决策树(CART)
介绍 决策树分为分类决策树和回归决策树: 上一篇介绍了分类决策树以及Python实现分类决策树: 监督学习——决策树理论与实践(上):分类决策树 决策树是一种依托决策而建立起来的一种 ...
- 单点登录--CAS认证--web.xml配置详解
参考网址: https://blog.csdn.net/zhurhyme/article/details/29349543 https://blog.csdn.net/shzy1988/article ...
- java学习-加载.properties工具类
javaWeb项目,要加载xxx.properties或其它如.txt, .md后缀的文本文件 文本内容有两种格式 key:value或者key=value 诸如Spring框架,Jfinal框架,都 ...
- docker(二)部署docker容器虚拟化平台
yum安装方法参考:https://www.cnblogs.com/yufeng218/p/8370670.html https://www.cnblogs.com/straycats/p/84112 ...