There are 10000 stations numbered from 0 to 9999. from each station , some load has to be transferred to another station by train . the fuel consumption of train between 2 successive station is 1 litre .
Find the minimum amount of fuel , in which loads can be transferred to all the destination stations.
constraints: the load for each station is between 1 and 100 inclusive. a train cannot carry more than 50 kgs of load at one time. a train cannot carry loads of several stations at the same time even if it can take more load . several stations can send their load to a station at the same time.
the first train leaves station 0.
Input : the destination station and load to be transferred for each of the 10000 stations.