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;
}

8840: Medical Checkup相关推荐

  1. [UPC](8840)Medical Checkup ---- 思维

    题目链接 Hint: ICPC 2017 Japan Tsukuba 题意: 有n个同学排成一队,要去体检1,2,3,4,--等等几个体检项目,同学的编号也是1,2,3,-- n 要求:必须要个遵守同 ...

  2. 【Asia-Tsukuba 2017 】problem C - Medical Checkup

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

  3. codeforces 101986 C Medical Checkup

    http://codeforces.com/gym/101986/problem/C 题目大意:体面太长懒得放,大概说一下题意.有 n n n个人排队依次进行体检,第 i i i个人进行一次体检所花费 ...

  4. Medical Checkup ---ACM

    思路 结论题: 先不考虑题目给的t是多少. 对于第i个人 (1)把第一个项目做完所需要的时间为sum(h1+h2+-+ hi ); (2)把第j ( j > 1) 个项目做完所需要的时间均为ma ...

  5. C - Medical Checkup Aizu - 1380

    题目https://vjudge.net/problem/Aizu-1380 想的太复杂了,真的,写都不好写,写完了也写wa了: 把我心态都搞崩了. 思路: 如果画一个区间图,仔细分析的话,就会发现, ...

  6. Medical Checkup Gym - 101986C

    https://cn.vjudge.net/problem/Gym-101986C 思路:等多久取决于要等最久的: 9  7   2   10   12 ----------------------- ...

  7. WordNet、FrameNet 同义词及相关词汇查询

    WordNet.FrameNet 同义词及相关词汇查询 WordNet.FrameNet 相关Python API 使用,请参考链接: WordNet Python API (整理总结) FrameN ...

  8. 【考研英语语法】动词练习题

    文章目录 Be 动词 1. be动词练习 2. Be 的一般疑问句的形式 2.1 一般疑问句构造训练 3. Be 的特殊疑问句 4. Be 的否定形式 5. Be 的过去式 6. Be 过去式的否定形 ...

  9. 2018年第四阶段组队训练赛第七场

    A: Secret of Chocolate Poles 题目描述 Wendy, the master of a chocolate shop, is thinking of displaying p ...

最新文章

  1. python输入多个数字后续操作_有效地确定后续数字范围中的数字是否在有序列表中. (在Python中)...
  2. 使用Sublime Text 3作为Python编辑器有关中文问题
  3. 全球大半网络瘫痪,背后原因竟来自这家无名小公司
  4. Python之第一个helloworld的代码
  5. jdbc版本低MySQL版本高_Mysql JDBC驱动版本与Mysql版本的对应问题解决
  6. centos安装mysql5.6系统崩溃_CentOS中安装MySQL5.6报错的解决方法
  7. 《四 spring源码》spring的事务注解@Transactional 原理分析
  8. 用excel产生多组随机抽签数
  9. vue中虚拟dom和diff算法
  10. UCF Local Programming Contest 2016 K. Bouncing Bunnies 最短路
  11. 设计模式【2.1】-- 简单工厂模式怎么演变成工厂方法模式?
  12. Android如何获取Wifi名称(SSID)
  13. 爬虫模拟登陆的几种方法
  14. stm32 hid 双向通信
  15. 【JQuery】动画
  16. 知乎神回复:曾经删了雷军代码的人现在怎么样了?
  17. 【矩阵论】矩阵的相似标准型(1)
  18. xshell突出显示集——自定义配置
  19. C/C++黑魔法-没有临时值的交换
  20. uniapp获取用户昵称头像

热门文章

  1. vue点击按钮实现跳转到另一个vue页面
  2. python岗位任职要求-2020 python web开发就业要求锦集
  3. selenium中使用阿布云代理
  4. Java实现年龄计算
  5. 微信一键登录遇到的坑
  6. 苹果无线网服务器改什么速度快,iPhone11无线网速比较慢 这样就可以改变网速慢的问题...
  7. vue项目中使用lodop实现打印
  8. python + Qt5 + opengl 绘制魔方(一)
  9. stm32h750电路_基于STM32H750的开发板,可用于评估,学习和开发
  10. 应用提交应用宝时提示:开发者与作者不符