Aizu - 1380—Medical Checkup (思路)

Students of the university have to go for a medical checkup, consisting of lots of checkup items, numbered 1, 2, 3, and so on.

Students are now forming a long queue, waiting for the checkup to start. Students are also numbered 1, 2, 3, and so on, from the top of the queue. They have to undergo checkup items in the order of the item numbers, not skipping any of them nor changing the order. The order of students should not be changed either.

Multiple checkup items can be carried out in parallel, but each item can be carried out for only one student at a time. Students have to wait in queues of their next checkup items until all the others before them finish.

Each of the students is associated with an integer value called health condition. For a student with the health condition hh, it takes hh minutes to finish each of the checkup items. You may assume that no interval is needed between two students on the same checkup item or two checkup items for a single student.

Your task is to find the items students are being checked up or waiting for at a specified time tt.

Input

The input consists of a single test case in the following format.

nn tt
h1h1
...
hnhn

nn and tt are integers. nn is the number of the students (1≤n≤1051≤n≤105). tt specifies the time of our concern (0≤t≤1090≤t≤109). For each ii, the integer hihi is the health condition of student ii (1≤h≤1091≤h≤109).

Output

Output nn lines each containing a single integer. The ii-th line should contain the checkup item number of the item which the student ii is being checked up or is waiting for, at (t+0.5t+0.5) minutes after the checkup starts. You may assume that all the students are yet to finish some of the checkup items at that moment.

Sample Input 1

3 20
5
7
3

Sample Output 1

5
3
2

Sample Input 2

5 1000000000
5553
2186
3472
2605
1790

Sample Output 2

180083
180083
180082
180082
180082

题意:

编号1-n个的人排队检查身体,需要检查很多项,每个人每一项的检查时间是固定的,前面的人没检查完,后面的只能等着,问t时间过后,每个人在哪一项检查或在哪一项等待。

思路:

每个人的进度不取决于他自身的检查时间,而取决于他之前的检查最慢的那个人

详见代码

#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;
typedef long long ll;
ll p[100005];
bool mark[100005];
ll s[100005];
int main()
{
    ll n,t;
    scanf("%lld%lld",&n,&t);
    for(int i = 0; i < n; ++i)
    {
        scanf("%lld",&p[i]);
    }
    s[0] = p[0];
    for(int i = 1; i < n; ++i)
        s[i] = s[i-1] + p[i];//算出编号为i的人检查完第一项一共度过的时间
    ll maxn = p[0];
    printf("%lld\n",t/maxn+1);//单独输出第一个人
    for(int i=1; i<n; ++i)
    {
        if(p[i] > maxn)//更新最慢检查时间
        {
            maxn = p[i];
        }
        if(s[i] > t) printf("1\n");//从第二个人开始,如果时间都不够检查完第一项,那么只好在第一项那等着了
        else printf("%lld\n",(t-s[i])/maxn+2);//剩余时间能检查的项数,+2是因为第一项包含在s[i]中了
    }
    return 0;
}

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值