【Asia-Tsukuba 2017 】problem C - Medical Checkup

题目链接http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1380

 

题目:

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

题目大意:

n个人依次排队轮流进行多项检查,第i个人进行一项检查消耗hi分钟,求第t分钟每个人正在进行的检查的编号数目或者正在等待的检查的编号数目。

解题思路:

对于第一个人来说,其输出为 t/h1+1,

对第i个人来说,

若已排到他(即t>=sum)则,其输出为(t - (  h1  +  h2  +  .... +  hi-1  +hi ) ) / max(h1,h2 , .... , hi)    + 2,

(解释:t - (  h1  +  h2  +  .... +  hi-1  +hi ) ) 为其排完第一个后剩余时间,用其除以其以及前面人中检查所用的最长时间即为其能检查的数目,再加上1(为第一个检查),再加1(如果刚好整除,则进入下一个或者等待下一个,需加一;如果没有整除,则正在进行下一项,则亦需加一))

否则其输出为1;

代码:

#include<cstdio>
#include<cmath>

#include<iostream>

 

using namespace std;
int main()
{

 

int m=-1,q;

        long long n, t, sum = 0;

 

scanf("%d %d", &n, &t);
for(int  i = 1  ; i <= n ; i ++ ){
cin>>q;
m=max(m,q);
sum+=q;
if( t >= sum ) printf("%lld\n", (t - sum ) /m + 2);
else printf("1\n");
}
}

 

--------------------------------------

www第一次哎!!!!!!

嘻嘻嘻嘻!!!

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值