Пример #1
0
        public void Solve()
        {
            int result = 0;

            ReadInput();

            for (int columnIndex = 0; columnIndex < HeightMap.Count(); columnIndex++)
            {
                for (int rowIndex = 0; rowIndex < HeightMap[columnIndex].Count(); rowIndex++)
                {
                    if (columnIndex <= 0 || HeightMap[columnIndex - 1][rowIndex] > HeightMap[columnIndex][rowIndex])
                    {
                        if (columnIndex >= HeightMap.Count() - 1 || HeightMap[columnIndex + 1][rowIndex] > HeightMap[columnIndex][rowIndex])
                        {
                            if (rowIndex <= 0 || HeightMap[columnIndex][rowIndex - 1] > HeightMap[columnIndex][rowIndex])
                            {
                                if (rowIndex >= HeightMap[columnIndex].Count() - 1 || HeightMap[columnIndex][rowIndex + 1] > HeightMap[columnIndex][rowIndex])
                                {
                                    result += HeightMap[columnIndex][rowIndex] + 1;
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine($"{result} is the result");
        }