public static IList <string> Solve(string[] inputLines) { var results = new List <string>(); var tests = int.Parse(inputLines[0]); var testCases = new List <CoreTestCase>(); int line = 1; for (int i = 0; i < tests; i++) { var lineTokens = inputLines[line++].Split(' '); var testCase = new CoreTestCase { N = int.Parse(lineTokens[0]), K = int.Parse(lineTokens[1]) }; testCase.U = decimal.Parse(inputLines[line++]); lineTokens = inputLines[line++].Split(' '); testCase.P = lineTokens.Select(decimal.Parse).ToArray(); testCases.Add(testCase); } foreach (var testCase in testCases) { results.Add(Solve(testCase)); } return(results); }
private static string Solve(CoreTestCase testCase) { while (testCase.U > 0) { var smallestIndex = MinIndex(testCase.P); testCase.U -= 0.0001m; testCase.P[smallestIndex] += 0.0001m; } return(testCase.P.Aggregate(1m, (v1, v2) => v1 * v2).ToString()); }