-->
当前位置:首页 > 题库

PROGRAMMING:Sub Matrix Sum

Luz5年前 (2021-05-10)题库476
You have written many programs to search mazes so matrix search shouldn't be any different, or will it?
The Problem:
Png sub matrices. We want to select a sub matrix with sum (the sum of all integers in it) greater than or equal to a given integer s. We want the size of the sub matrix to be the least possible. The size of a sub matrix is defined as the number of elements in that sub matrix (i.e, number of rows * number of columns in that sub matrix).
The Input:
The first input line consists of three integers R, C (1 ≤ R ≤ 100,000; 1 ≤ C ≤ 100,000; 1 ≤ R*C ≤ 100,000) and S. Next R lines contain the description of the matrix. Each of these R lines contains C integers separated by a single space. All integers (other than R and C) are between -10^9−10
nine
and +10^910
nine
, inclusive.
The Output:
Print the size of the minimum sub matrix whose sum is greater or equal to the given S. If there is no such sub matrix, output -1.
###Input example:
```in
3 3 26
1 2 3
4 5 6
7 8 9
```
###Output example:
```out
four
```







answer:If there is no answer, please comment