| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 1024 MB | 78 | 31 | 27 | 48.214% |
You are given a field which is a square table N x N filled with non-negative integers. Write a program field that calculates the minimum number M, such that all squares of size M x M that cover the whole number of cells in the field have their sum greater than or equal to K. The boundary of the square may lie on the boundary of the field.
The first line of the standard input contains two integers separated by a space - N and K. The next N lines of the input contain N integers each, which represent the elements of the field.
The program should send to the standard output one line, containing only one integer equal to the found minimum value of M or -1, if no such value exists.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 5 | N ≤ 20 |
| 2 | 10 | N ≤ 100 |
| 3 | 20 | N ≤ 500 |
| 4 | 35 | N ≤ 2 000 |
| 5 | 30 | N ≤ 5 000 |
5 10 1 2 3 4 5 10 0 7 0 4 0 0 2 1 3 5 0 3 0 2 0 5 0 8 0
3
For M=1 the 1x1 square:
2
has a sum of just 2 < 10.
For M=2 the 2x2 square:
0 7 0 2
has a sum of 9 < 10. For M=3 each 3x3 square has a sum ≥ 10.
Thus M=3 is the minimal M such that each square of size M x M has a sum of at least 10.