8840: Medical Checkup

6 篇文章 0 订阅

8840: Medical Checkup

http://exam.upc.edu.cn/problem.php?id=8840

时间限制: 2 Sec  内存限制: 128 MB
提交: 184  解决: 52
[提交] [状态] [讨论版] [命题人:admin]

题目描述

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 h, it takes h 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 t.

 

输入

The input consists of a single test case in the following format.
n t
h1
.
.
.
hn
n and t are integers. n is the number of the students (1 ≤ n ≤ 105). t specifies the time of our concern (0 ≤ t ≤ 109). For each i, the integer hi is the health condition of student i(1 ≤ hi ≤ 109).

 

输出

Output n lines each containing a single integer. The i-th line should contain the checkup item number of the item which the student i is being checked up or is waiting for, at (t+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.

 

样例输入

3 20
5
7
3

 

样例输出

5
3
2

题意:n个人依次排队且按体检点顺序体检,一个体检的地方每次只能体检一人,一个人在这个体检点没体检完后一个必须等。

第i个人体检hi时间,问t时这n个人现在在哪个体检点体检或等待?

思路:画画图就能得到公式,但比赛的时候一直输出超限。。。愁死了。。。

代码:

#include<iostream>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#define inf 0x3f3f3f3f
using namespace std;

int h[100005];

int main()
{
    int n,t;
    long long summ;
    cin>>n>>t;
    for(int i=1;i<=n;i++)
        cin>>h[i];
    int maxx=h[1];
    summ=t/h[1]+1;
    cout<<summ<<endl;
    long long sum=h[1];
    for(int i=2;i<=n;i++)
    {
        sum+=h[i];
        maxx=max(maxx,h[i]);
        if(t<sum)
            cout<<"1"<<endl;
        else
        {
            summ=(t-sum)/maxx+2;
            cout<<summ<<endl;
        }
    }
    return 0;
}

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值