Medical Checkup
Time limit2sMemory limit512 MB
Given n students in a fixed queue and their per-item service times, report the item each student is on or waiting for at time t+0.5.
- Level
Hard8 of 10
- Topics
- Simulation, Math, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
Every student at the university has to take a medical checkup. The checkup items are numbered 1, 2, 3, and so on, and there is no limit on the number of items.
The students stand in one long queue, waiting for the checkup to start. They are numbered 1, 2, 3, and so on from the front of the queue. A student has to take the items in increasing order of the item number, skipping none of them and reordering none of them. The order of the students does not change either.
Different items run in parallel, but one item handles only one student at a time. A student therefore waits in the queue of the next item until everyone ahead has finished that item.
Each student has an integer value called the health condition. A student whose health condition is needs minutes to finish each item. Assume that no time passes between two students on the same item, and none between two items of the same student.
Find, at a given moment, the item that each student is being checked on or is waiting for.
Input
The input is a single test case in the following format.
n t
h1
.
.
.
hn
and are integers. is the number of students (), and is the moment of interest (). For each , the integer is the health condition of student ().
Output
Print lines, each holding a single integer. Line holds the number of the item that student is being checked on or is waiting for, at minutes after the checkup starts. You may assume that every student still has items left to finish at that moment.