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

输入描述
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.

输出描述
There are one number indicates the answer to the question in a line for each case.

输入样例
4
1 2 3 4

输出样例
1


最后期限大于1000000的可以直接忽略,从1到1000000遍历一下所需人数的最大值即可,注意:不能用cin输入,效率太低

#include"iostream"
#include"string.h"
#include<map>
#include"stdio.h"
using namespace std;
const int max_zhi=1e6;

int ai;
int ji[max_zhi+20];
int main()
{
    int n;
    while(cin>>n)
    {
        memset(ji,0,sizeof(ji));
        int mmax=1;
        for(int i=0;i<n;i++)
        {
            scanf("%d",&ai);
            if(ai>max_zhi+10) continue;
            ji[ai]++;
        }
        for(int i=1;i<=max_zhi+10;i++)
        {
            ji[i]+=ji[i-1];
            int cha=(ji[i]*1.0)/i+0.9999;
            if(cha>mmax) mmax=cha;
        }
        cout<<mmax<<endl;
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值