407084: GYM102697 055 Train-ficiency
Description
A train station needs your help to maximize its efficiency. The train station can only have 100 train carts parked on a track at once, and it is imperative that the tracks are fully filled as to maximize profit. Given a list of trains and their lengths (number of train carts) print the pairs of trains that will most effectively fill the station.
InputYou will be given 4 integers separated by spaces. Each of these integers represents the number of cars on a train.
OutputPrint the pairs of trains.
ExamplesInput25 50 50 75Output
Train 1 and Train 4 Train 2 and Train 3Input
35 24 65 76Output
Train 1 and Train 3 Train 2 and Train 4Note
In the first case, Train 1 must be combined with Train 4, as 25 cars plus 75 cars adds up to 100 cars. Train 3 must be combined with Train 4, as 50 cars plus 50 cars equals 100 cars.
Also, assume that there is always a way to fill each track with 100 trains. Make sure the output format puts the trains in ascending order (i.e. Train 1 and Train 3, not Train 3 and Train 1).