public static void Solve() { var n = ConsoleHelper.ReadLineAs <int>(); var sachaCards = ConsoleHelper.ReadLineAndSplit(); var myCards = ConsoleHelper.ReadLineAndSplit(); var best = FindBest(myCards.ToList(), sachaCards, 0); var res = best.Item1 ? string.Join(" ", best.Item2) : "-1"; ConsoleHelper.WriteLine(res); }
public static void Solve() { ReadMap(); var robotCount = ConsoleHelper.ReadLineAs <int>(); var robots = new Robot[robotCount]; for (var k = 0; k < robotCount; k++) { var input = ConsoleHelper.ReadLineAndSplit(); var x = int.Parse(input[0]); var y = int.Parse(input[1]); var direction = input[2].ToCharArray()[0]; var robotGroup = group[y, x]; var robot = new Robot(k, x, y, direction, robotGroup); robots[k] = robot; } var commands = new List <Command>(); foreach (var robotGroup in robots.GroupBy(r => r.Group)) { var groupCommands = Solve(robotGroup.Key, robotGroup.ToArray()); commands.AddRange(groupCommands); } ConsoleHelper.WriteLine(string.Join(" ", commands)); }
public static void Solve() { var n = ConsoleHelper.ReadLineAs <int>(); var m = ConsoleHelper.ReadLineAs <int>(); var capacity = m * 10; var lasTime = 0; var people = 0; var sonore = false; var duration = 0; for (var i = 0; i < n; i++) { var input = ConsoleHelper.ReadLineAndSplit(); var h = input[0].Split(':'); var time = int.Parse(h[0]) * 60 + int.Parse(h[1]); var p = input[1]; if (sonore) { duration += time - lasTime; } if (p == "E") { people++; } else { people--; } if (people > capacity) { sonore = true; } else { sonore = false; } lasTime = time; } if (sonore) { duration += 23 * 60 - lasTime; } ConsoleHelper.WriteLine(duration); }
public static void Solve() { var n = ConsoleHelper.ReadLineAs <int>(); var similar1 = 0; var similar2 = 0; for (var i = 0; i < n; i++) { var input = ConsoleHelper.ReadLineAndSplit(); var f = input[0]; var d = input[1]; var occurenceF = new int[26]; var occurenceD = new int[26]; foreach (var c in f) { occurenceF[c - 'a']++; } foreach (var c in d) { occurenceD[c - 'a']++; } var similar = 0; for (var k = 0; k < 26; k++) { similar += Math.Min(occurenceD[k], occurenceF[k]); } if (similar == 1) { similar1++; } else if (similar >= 2) { similar2++; } } var prio = (similar1 + similar2 - 1) % 2; var res = prio == 0 ? "DEBUNK" : "FAKE"; ConsoleHelper.WriteLine(res); }
public static void Solve() { var input = ConsoleHelper.ReadLineAndSplit(); var n = int.Parse(input[0]); var s = input[1]; var deeRounds = 0; var dumRounds = 0; for (var i = 0; i < n; i++) { var stack = ConsoleHelper.ReadLine(); if (stack.Length == 0) { continue; } var last = 'x'; foreach (var current in stack) { if (last == current) { continue; } if (current == '0') { deeRounds++; } else { dumRounds++; } last = current; } } var winner = (deeRounds < dumRounds || deeRounds == dumRounds && s == "Dee") ? "Dee" : "Dum"; ConsoleHelper.WriteLine(winner); }
public static void Solve() { var n = ConsoleHelper.ReadLineAs <int>(); var price = ConsoleHelper.ReadLineAs <int>(); var res = "KO"; for (var i = 0; i < n; i++) { var input = ConsoleHelper.ReadLineAndSplit(); var p = int.Parse(input[0]); var e = input[1]; if (p > price) { price = p; res = e; } } ConsoleHelper.WriteLine(res); }
public static void Solve() { var n = ConsoleHelper.ReadLineAs <int>(); var min = int.MaxValue; var res = ""; for (var i = 0; i < n; i++) { var split = ConsoleHelper.ReadLineAndSplit(); var name = split[0]; var size = int.Parse(split[1]); if (size < min) { min = size; res = name; } } ConsoleHelper.WriteLine(res); }
private static Game ReadRound() { var game = new Game { Players = new[] { new Player(), new Player(), new Player() } }; game.Players[0].Score = int.Parse(ConsoleHelper.ReadLine()); game.Players[1].Score = int.Parse(ConsoleHelper.ReadLine()); game.Players[2].Score = int.Parse(ConsoleHelper.ReadLine()); game.Players[0].Rage = ConsoleHelper.ReadLineAs <int>(); game.Players[1].Rage = ConsoleHelper.ReadLineAs <int>(); game.Players[2].Rage = ConsoleHelper.ReadLineAs <int>(); var unitCount = ConsoleHelper.ReadLineAs <int>(); for (var i = 0; i < unitCount; i++) { var inputs = ConsoleHelper.ReadLineAndSplit(); var entity = EntityBuilder.Build(inputs); if (Trace > 0) { ConsoleHelper.Debug(entity); } // Not enabled on CG ! //switch (entity) if (entity is Reaper reaper) { game.Players[reaper.Player].Reaper = reaper; } else if (entity is Destroyer destroyer) { game.Players[destroyer.Player].Destroyer = destroyer; } else if (entity is Doof doof) { game.Players[doof.Player].Doof = doof; } else if (entity is Tanker tanker) { game.Tankers.Add(tanker); } else if (entity is Wreck wreck) { game.Wrecks.Add(wreck); } else if (entity is Tar tar) { game.Tars.Add(tar); } else if (entity is Oil oil) { game.Oils.Add(oil); } else { throw new NotImplementedException(); } } return(game); }