@@ -0,0 +1,834 @@
+// https://community.topcoder.com/stat?c=problem_statement&pm=2980%0A%0Apublic class FuelConsumption %7B%0A%09public static double maximalDistance(int%5B%5D velocities, int%5B%5D consumptions, int fuel) %7B%0A%09%09double maxDistanceTravelled = 0.0d;%0A%09%09%0A%09%09for (int i = 0; i %3C velocities.length; ++i) %7B%0A%09%09%09int fuelLeft = fuel;%0A%09%09%09double distanceTravelled = 0.0d;%0A%09%09%09%0A%09%09%09while (fuelLeft %3E= consumptions%5Bi%5D) %7B%0A%09%09%09%09distanceTravelled += velocities%5Bi%5D;%0A%09%09%09%09fuelLeft -= consumptions%5Bi%5D;%0A%09%09%09%7D%09%0A%09%09%09%0A%09%09%09double time = ( (double) fuelLeft / consumptions%5Bi%5D );%0A%09%09%09double distanceTravelledFromFuelLeft = velocities%5Bi%5D * time; // based on formula Distance = Speed * Time%0A%09%09%09distanceTravelled += distanceTravelledFromFuelLeft;%0A%09%09%09%0A%09%09%09if (distanceTravelled %3E maxDistanceTravelled) %7B%0A%09%09%09%09maxDistanceTravelled = distanceTravelled;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return maxDistanceTravelled;%0A%09%7D%0A%7D%0A

Create FuelConsumption.java