Maximum Area
Practice
4.1 (15 votes)
Algorithms
Graphs
Medium
Shortest path algorithm
Problem
85% Success 1695 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

While walking around Hackerland, Marichka found a large square grid of size \(N\cdot N\) consisting of unit squares of size \(1\cdot1\). Now Marichka wants to explore it as much as possible.

In one move Marichka can move to the cell which shares an edge with cell, where Marichka currently is. It will take her \(a_{ij}\) (\(1 \le a_{ij} \le 10^{6}\)) minutes, where \((i,j)\) is the coordinates of the cell where Marichka moved. Marichka defines her exploration level as the maximum row number for all cells she visited multiplied by maximum column number for all cells she visited. Marichka always starts her exploration in the cell with coordinates \((1,1)\). Your task is to help Marichka maximize this score. Marichka is limited in time, so she can't spend more than \(T\) minutes exploring the grid.

Input format

The first line contains two integers \(N, T\) (\(1 \le N \le 150, 1 \le T \le 10^{9}\)) --- size of the grid.
Each line \(i\) of the \(N\) subsequent lines (where \(1 \le i \le N\)) contains \(N\) integers describing \(i\)-th row of the grid --- \(a_{i1}, a_{i2}, ..., a_{in}\).

Output format

Output maximum Marichka's exploration level.

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
7 votes
Tags:
ApprovedGraphsMathMediumOpenShortest Path Algorithm
Points:30
5 votes
Tags:
AlgorithmsApprovedBreadth First SearchGraphsMediumOpen
Points:20
11 votes
Tags:
Basic ProgrammingEasyOpenApprovedHash table