Refueling Vehicles

Company: HMEL

Difficulty: easy

Problem Statement

Refueling Vehicles You are in charge of a convoy of N vehicles. Each vehicle has a fuel meter showing the fuel currently present in that vehicle, in litres. Every vehicle has to travel the same distance of X kilometres. A vehicle covers exactly 1 kilometre using 1 litre of fuel. The convoy moves one vehicle at a time, and the vehicles behave as follows: If the fuel available to a vehicle would run out before it has covered X kilometres, the vehicle stops and refuels. A refuelling always delivers exactly X litres , regardless of how much fuel the vehicle was short by. If a vehicle finishes its X kilometres with fuel left over, that leftover fuel is handed to the next vehicle in the convoy and is added to the fuel that vehicle already has. Leftover fuel from the last vehicle is simply discarded. You may rearrange the convoy into any order you like before it sets off. Choose the order that makes the convoy stop for fuel as few times as possible. Report the minimum total number of refuelli