using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace D6._2 { class Program { static void Main(string[] args) { if (args.Length < 3) return; if (File.Exists(args[0]) == false) return; if (int.TryParse(args[1], out int size) == false) return; if (int.TryParse(args[2], out int ceil) == false) return; var coordinates = new List<(uint x, uint y)>(); var file = File.OpenText(args[0]); do { var line = file.ReadLine(); if (line == null) break; var cl = line.Split(", "); coordinates.Add((uint.Parse(cl[0]), uint.Parse(cl[1]))); } while (true); int area = 0; for (uint x = 0; x < size; x++) { for (uint y = 0; y < size; y++) { var total = GetTotalDistance(ceil, coordinates, (x, y)); if (total < ceil) area++; } } Console.WriteLine($"Answer : {area}"); } private static int GetTotalDistance(int ceil, List<(uint x, uint y)> coordinates, (uint x, uint y) point) { int total = 0; for (int i = 0; i < coordinates.Count; i++) { var (x, y) = coordinates[i]; var manhattan = Math.Abs((int)point.x - (int)x) + Math.Abs((int)point.y - (int)y); total += manhattan; if (total >= ceil) break; } return total; } } }