internal static Horse Read(TextReader reader) { int[] positionSpeed = PonyExpress.ReadIntArray(reader); return(new Horse { Speed = positionSpeed[1], Position = positionSpeed[0], }); }
public static double Solve(TextReader reader) { int[] targetHorseCount = PonyExpress.ReadIntArray(reader); int target = targetHorseCount[0]; int horseCount = targetHorseCount[1]; double worstTime = 0; for (int i = 0; i < horseCount; i++) { Horse horse = Horse.Read(reader); double time = (target - horse.Position) / horse.Speed; worstTime = Math.Max(worstTime, time); } return(target / worstTime); }
public static string Solve(TextReader reader) { int[] stallsColorings = PonyExpress.ReadIntArray(reader); int stalls = stallsColorings[0]; int[] initialColorings = stallsColorings.Skip(1).ToArray(); for (int startCharIndex = 0; startCharIndex < initialColorings.Length; startCharIndex++) { int[] coloring = (int[])initialColorings.Clone(); var result = Coloring(stalls, coloring, startCharIndex); if (result != null) { return(result); } } return("IMPOSSIBLE"); }