华中农业大学第五届程序设计大赛网络同步赛-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 ...
随机推荐
- spark踩坑——dataframe写入hbase连接异常
最近测试环境基于shc[https://github.com/hortonworks-spark/shc]的hbase-connector总是异常连接不到zookeeper,看下报错日志: 18/06 ...
- ping端口是否开放(windows,macos,linux)
windows中ping端口:tcping命令 1. tcping 非自带命令,首先安装tcping命令,也可以去官网:http://www.elifulkerson.com/projects/tcp ...
- Java按时间梯度实现异步回调接口
1. 背景 在业务处理完之后,需要调用其他系统的接口,将相应的处理结果通知给对方,若是同步请求,假如调用的系统出现异常或是宕机等事件,会导致自身业务受到影响,事务会一直阻塞,数据库连接不够用等异常现象 ...
- postgresql和redis
redis 和postgresql区别以及其优缺点 一刹那者为一念,二十念为一瞬,二十瞬为一弹指,二十弹指为一罗预,二十罗预为一须臾,一日一夜有三十须臾. 那么,经过周密的计算,一瞬间为0.36 秒, ...
- (转)9 db2trc案例2(1,2)
原文:http://book.51cto.com/art/200906/130068.htm 9.3.3 db2trc案例2(1) 在AIX操作系统上,系统原先运行良好,而后用户从DB2 V8 FP ...
- (转)Python3之requests模块
原文:https://www.cnblogs.com/wang-yc/p/5623711.html Python标准库中提供了:urllib等模块以供Http请求,但是,它的 API 太渣了.它是为另 ...
- Linux下安装Nginx详细图解教程 (nginx-1.2.6)
什么是Nginx? Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器,在高连接并发的情况下N ...
- php -- 文件上传下载
----- 026-upload.php ----- <!DOCTYPE html> <html> <head> <meta http-equiv=" ...
- WPF中的TextBlock隐藏边框
TextBlock默认是有边框的,显示效果如下:有一个淡蓝色的边框围绕着 如果需要隐藏这个边框,则只需要在代码中加上以下代码即可: BorderBrush="{x:Null}" B ...
- 200个最常见的JAVA面试问题(附答案)
本文内容: 20个最常见的JAVA面试问题(附答案) 13个单例模式JAVA面试问题(附答案) 说说JVM和垃圾收集是如何工作的(附答案) 说说如何避免JAVA线程死锁(附答案) Java中HashS ...