The Problem of Train Setout
Time Limit: 1 Second Memory Limit: 32768 KB
At a railway station there is only one channel. There are two kinds of train: the express train and ordinary train. The ordinary train should wait to setout until all the express train have setout. But if an ordinary train is just setouting, the incoming express train should wait until the ordinary train leaves. The leaving time of express train and ordinary train are Le and Lo. And the time between the arriving of two express train is Ae and of ordinary train is Ao. The total ovservation time is T.
You should work out a program to illustrate the number of trains waiting to setout at any time, and calculate the average time of the two kinds of train waiting We, Wo, and the average time of the all trains waiting Wt, and the time every train waited W(t).
Assume that the setout channel is empty at first and an express train comes first. The first ordinary train comes at Ao.
Input
The input is a line of five numbers that represent Ae, Ao, Le, Lo, T respectively.
Process to the end of file.
Output
The first part of the output is an array of the waiting trains, one element per line. There are three numbers in a line. First is the time, second is the number of waiting express trains, the third is the number of waiting ordinary trains. Only print this when the numbers are changed. At the end of the array, there is a 0.
After the array, there is a line contains three numbers are We, Wo, Wt.
The last part of the output is also an array, one element per line. There are two elements per line. The first one is the train. If the train is an express train, then the first element begins with E, followed by the number of express train, (the number is according to the incoming ordre of the train); else it begins with O, followed by the number of the ordinary train. The second is the time the train has waited.
Sample Input
3 6 6 2 30
Sample Output
0 0 0 3 1 0 6 1 1 9 2 1 12 2 2 15 3 2 18 3 3 21 4 3 24 4 4 27 5 4 30 5 5 0 6 12 8 E1 0 E2 3 E3 6 E4 9 E5 12 E6 15 E7 12 E8 9 E9 6 E10 3 E11 0 O1 24 O2 18 O3 12 O4 6 O5 0Submit
Source: Asia 1996, Shanghai (Mainland China)