/// <summary> /// Reads a test case /// </summary> /// <param name="input"></param> /// <returns></returns> public CodeJamProblem BuildProblem(CodeJamInput input) { string[] numbers = input.NextLine().Split(' '); this.r = long.Parse(numbers[0]); this.t = long.Parse(numbers[1]); return(this); }
/// <summary> /// Reads a test case and initializes the class' variables /// </summary> /// <param name="input"></param> /// <returns></returns> public CodeJamProblem BuildProblem(CodeJamInput input) { N = int.Parse(input.NextLine()); Graph = input.NextLine().Split(' ').Select(i => int.Parse(i) - 1).ToArray(); return(this); }
/// <summary> /// Reads a test case and initializes the class' variables /// </summary> /// <param name="input"></param> /// <returns></returns> public CodeJamProblem BuildProblem(CodeJamInput input) { N = int.Parse(input.NextLine()); Lists = new int[2 * N - 1][]; for (int i = 0; i < 2 * N - 1; i++) { Lists[i] = input.NextLine().Split(' ').Select(n => int.Parse(n)).ToArray(); } return(this); }
static void Main(string[] args) { //Reads the input CodeJamInput input = new CodeJamInput(); StringBuilder output = new StringBuilder(); foreach (CodeJamProblem p in input.problems) { //Solves each test case output.AppendLine(p.GetSolution()); } //Print results to file File.WriteAllText(outputPath, output.ToString()); }
/// <summary> /// Reads a test case /// </summary> /// <param name="input"></param> /// <returns></returns> public CodeJamProblem BuildProblem(CodeJamInput input) { string[] numbers = input.NextLine().Split(' '); this.MaxEnergy = long.Parse(numbers[0]); CurEnergy = MaxEnergy; this.R = long.Parse(numbers[1]); this.N = long.Parse(numbers[2]); R = R > MaxEnergy ? MaxEnergy : R; numbers = input.NextLine().Split(' '); values = new long[N]; for (int i = 0; i < N; i++) { values[i] = long.Parse(numbers[i]); } return(this); }
/// <summary> /// Reads a test case and initializes the class' variables /// </summary> /// <param name="input"></param> /// <returns></returns> public CodeJamProblem BuildProblem(CodeJamInput input) { S = input.NextLine(); return(this); }