The Problem of Train Setout
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 observation 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 a express train comes first. And the output channel will never be empty.
At the begin (time 0) express is just ariving. The firs ordinary train will arive at Ao.
The input is a lines of five numbers that represent Ae, Ao, Le, Lo, T respectively. Last line is
0 0 0 0 0
At the begin of each solution print "#Ae Ao Le Lo T"
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. 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 the express train, (the number is according to the incoming order 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.
3 6 6 2 30 0 0 0 0 0
#2 6 6 2 30 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 0 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 0