public static void Main(string[] args) { Encoding encoding = new UTF8Encoding(false); string inFilePath = "/gcj/2017/c/in.txt"; string outFilePath = "/gcj/2017/c/out.txt"; List <string> resultLines = new List <string>(); using (StreamReader inStream = new StreamReader(inFilePath, encoding)) { int casesCount = int.Parse(inStream.ReadLine()); for (int caseNumber = 1; caseNumber <= casesCount; caseNumber++) { CaseInfo c = CaseInfo.Parse(inStream); string solution = c.Solve(); Console.WriteLine("Case #" + caseNumber + ": " + solution); resultLines.Add("Case #" + caseNumber + ": " + solution); //break; } } File.WriteAllLines(outFilePath, resultLines, encoding); Console.ReadKey(); }
public static CaseInfo Parse(StreamReader inStream) { string line = inStream.ReadLine(); string[] lineParts = line.Split(); long distance = long.Parse(lineParts[0]); long guests = long.Parse(lineParts[1]); CaseInfo result = new CaseInfo(); result.Distances = new Dictionary <long, long>(); result.Distances[distance] = 1; result.Guests = guests; return(result); }