Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _05.Max_Platform_3_x_3
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- if (nums[0] < 3 || nums[1] < 3 || nums[0] > 1000 || nums[1] > 1000)
- {
- return;
- }
- else
- {
- int rows = Math.Abs(nums[0]);
- int cols = Math.Abs(nums[1]);
- var matrix = new int[rows][];
- for (int row = 0; row < rows; row++)
- {
- matrix[row] = Console.ReadLine().Split(' ')
- .Select(int.Parse).ToArray();
- }
- int counterRow = 0;
- int counterCol = 0;
- long sum = 0;
- for (int row = 0; row < rows - 2; row++)
- {
- for (int col = 0; col < cols - 2; col++)
- {
- long currentSum = matrix[row][col] + matrix[row][col + 1] + matrix[row][col + 2]
- + matrix[row + 1][col] + matrix[row + 1][col + 1] + matrix[row + 1][col + 2]
- + matrix[row + 2][col] + matrix[row + 2][col + 1] + matrix[row + 2][col + 2];
- if (currentSum > sum)
- {
- sum = currentSum;
- counterRow = row;
- counterCol = col;
- }
- }
- }
- Console.WriteLine(sum);
- for (int row = counterRow; row < counterRow + 3; row++)
- {
- for (int col = counterCol; col < counterCol + 3; col++)
- {
- Console.Write(matrix[row][col]);
- Console.Write(" ");
- }
- Console.WriteLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement