시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 0 | 0 | 0 | 0.000% |
In order to ensure that the contestants find it easy to reach the regional contest site, the authority has prepared some robot-driven vehicles. The vehicles would visit n predetermined junctions and carry the contestants waiting there to the contest. There is a computer controlled Transportation Center (TC) that determines the number of seats of each vehicle and the time each vehicle leaves the contest site for the first time.
When a new vehicle is needed, a request is made to the TC. Every new vehicle has fewer number of seats than the last vehicle if it is more than 3: the i-th vehicle has max(s-(i-1)*t, 3) seats (i = 1, 2, 3, ...). The first vehicle leaves the contest site just at 8:00am. When TC gets a request for a new vehicle, it prepares a new vehicle and right after 2 seconds of getting the request, the new vehicle leaves the contest site. If multiple requests are made at the same time, only one is considered.
At the junction j, each vehicle does the following tasks. If there are more than one vehicle at j at the same time, they perform the tasks in order of their service times: the one with the longest service time goes first. Service time of a vehicle is the difference between current time and the time the vehicle left the contest site (which is at junction 0) for the first time.
Vehicles do the above 3 tasks instantly (i.e. in 0 seconds). Time needed to go from each junction to any other junction is known. All the contestants reach a suitable junction by 8:00am and don't go away until they are picked up by any vehicle. Given the number of contestants waiting at each junction and a time limit, you are to determine when everyone reaches the contest or how many have reached the contest by the time limit.
Input consists of several datasets. Each dataset consists of the followings:
All integers on a single line are separated by exactly one space. Total number of contestants is at most 1000.
The end of input is marked with a line consisting of "TheEnd".
For each set, print 2 lines. The first line contains the name of the set as it appears in the input. The second line contains the time (in seconds) needed to bring all the contestants to the contest, if the time is not more than the given time limit. Otherwise, print the number of contestants reached the contest by the time limit (See the sample output).
Dhaka2000 3 22 4 30 8 10 30 28 8 20 20 100 Dhaka2001 3 22 4 30 8 10 30 28 8 20 20 90 Dhaka2002 3 22 2 30 8 10 30 28 8 20 20 100 TheEnd
Dhaka2000 98 seconds needed Dhaka2001 22 contestants reached Dhaka2002 88 seconds needed