The Problem of Train Setout |
At a railway station there is only one out channel. There are two kinds of trains : 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 trains 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.
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 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