华中农业大学第五届程序设计大赛网络同步赛-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 ...
随机推荐
- 详述MSSQL服务在渗透测试中的利用(上篇)
前言: 致力于复现最实用的漏洞利用过程. 本文将带领大家学习以下内容: 学习使用`xp_cmdshell`扩展存储过程 学习调用`wscript.shell` 学习MSSQL写文件 学习沙盘模式提权 ...
- Shell - 简明Shell入门13 - 用户输入(UserInput)
示例脚本及注释 1 - arguments #!/bin/bash if [ -n "$1" ];then # 验证参数是否传入 echo "The first para ...
- iOS-【最新】跳转到 App Store 评分
APP应用内 App Store 跳转评分 NSString *itunesurl = @"itms-apps://itunes.apple.com/cn/app/id你的APPid?mt= ...
- Ubutntu安装docker启动报Removed /etc/systemd/system/docker.service.
Ubutntu安装docker启动报Removed /etc/systemd/system/docker.service.的错误,只需要执行以下三条命令. systemctl unmask docke ...
- POJ 2601
#include<iostream> #include<iomanip> #include<stdio.h> using namespace std; int ma ...
- Android从零开始
Android开发环境的安装 1 IDE Android可以使用开发的IDE有Eclipse 或者 Android Studio.Android Studio还处于v 0.1.x版本,是early a ...
- Python:快速查找出被挂马的文件
网站被入侵,担心被挂马,因此就想自己写个脚本来查找那些被挂马的文件 思路 需要实现准备一份未受感染的源代码和一份可能受感染的源代码,然后运行以下脚本,就能找出到底哪些文件被挂马了. 其中,主要是根据比 ...
- 使用安装 php-memcache-client
1.memcache:是一个高效的分布式内存对象缓存系统 2. IES---请求--->服务器(apace) | | |---->会查看memcache.是否有IES想要的内容--> ...
- Configuration problem: Failed to import bean definitions from relative location
问题现象: 最近开始做新需求,然后在Tomcat上部署项目时,出现了如下报错: [12-05 09:54:27,161 ERROR] ContextLoader.java:351 - Context ...
- linux解压zip乱码解决方案
1.向系统添加windows下的字符编码: sudo vim /var/lib/locales/supported.d/local 添加一下编码: zh_CN.GBK GBK zh_CN.GB231 ...