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 MaxPlatform3_3
- {
- class Program
- {
- static void Main()
- {
- int[] dimennsions = Console.ReadLine().Split().Select(int.Parse).ToArray();
- int rows = dimennsions[0];
- int cols = dimennsions[1];
- int[][] matrix = new int[rows][];
- for (int row = 0; row < rows; row++)
- {
- matrix[row] = Console.ReadLine().Split().Select(int.Parse).ToArray();
- }
- long maximumSum = int.MinValue;
- int maxRow = 0;
- int maxCol = 0;
- for (int row = 0; row < rows-2; row++)
- {
- for (int col = 0; col < cols - 2; col++)
- {
- //ckeck cells
- long sum = (long)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(sum > maximumSum)
- {
- maximumSum = sum;
- maxRow = row;
- maxCol = col;
- }
- }
- }
- Console.WriteLine(maximumSum);
- for (int row = maxRow; row < maxRow+3; row++)
- {
- for (int col = maxCol; col < maxCol+3; col++)
- {
- Console.Write(matrix[row][col] + " ");
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment