HZAU 1209 Deadline
来源:互联网 发布:os x 怎么恢复mac系统 编辑:程序博客网 时间:2024/05/24 15:38
1209: Deadline
Time Limit: 2 Sec Memory Limit: 1280 MBSubmit: 1046 Solved: 102
[Submit][Status][Web Board]
Description
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
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
There are one number indicates the answer to the question in a line for each case.
Sample Input
4 1 2 3 4
Sample Output
1
HINT
题意:
有n(1<=n<=1000000)个bug需要程序猿来调试,程序员每天可以调试出1个bug,每个bug都必须在xi天前(包括xi)调试出来,求出所需最小程序猿的个数。
思路:
我们首先可以把最后期限xi大于n的不进行统计,因为xi大于n时最多也就只需要1个程序员,那么我们枚举天数1到n一共有多少个bug,bug的数量除于天数可得出到该天时所需要的程序员,如果还有余数那么我们还得再增加一个程序员。
举个例子:
5
1 2 2 3 4
第1天:1/1=1,num=1
第2天:3/2=1......1,num=2
第3天:4/3=1......1,num=2
第4天:5/4=1......1,num=2
第5天:5/5=1,num=1
所需最少的程序员就是2个。
Source
示例程序
#include <cstdio>#include <cstring>#include <algorithm>int a[1000001];//n最大为1000000,因此数组开到1000000即可using namespace std;int main(){ int n,i,x,maxx,num,t; while(scanf("%d",&n)!=EOF) { memset(a,0,sizeof(a)); maxx=1; num=0; for(i=1;n>=i;i++) { scanf("%d",&x); if(x<=n) { a[x]++; } } for(i=1;n>=i;i++) { num=num+a[i]; t=num/i; if(num%i!=0) { t++; } maxx=max(maxx,t); } printf("%d\n",maxx); } return 0;} /************************************************************** Problem: 1209 Code Length: 740 B Language: C++ Result: Accepted Time:1088 ms Memory:4940 kb****************************************************************/
- hzau 1209 Deadline 思维@
- HZAU 1209 Deadline
- HZAU 1209 Deadline (技巧)
- HZAU 1209 Deadline (hash 贪心 水题不水)
- Deadline
- waiting deadline
- 论文deadline。。。
- HZAU 1000 Enrolling
- HZAU 1005 Balance
- HZAU 1003 Alien invasion
- HZAU 1018 Catching Dogs
- HZAU 1017 Eat Candy
- HZAU 异或问题
- HZAU 1205 Sequence Number
- HZAU 1208 Color Circle
- hzau training20170121 a
- hzau training 20170121 b
- hzau 20170121 c
- codeforces E. Kidnapping(记忆化搜索)
- C语言---使用main函数的参数,实现一个整数计算器
- (四)android recovery 升级之USB设备挂载
- leapmotion文档(3):创建一个unity3d项目
- IMWeb 前端小白 动物卡 作业
- HZAU 1209 Deadline
- linux 软连接和硬链接
- Nginx 基础 总结
- hdu2102 A计划 广搜
- sqlserver存储过程输出参数
- 程序和进程的区别
- Thinkphp3.23下实现文件下载功能
- POJ
- tensorflow总结帖