作者:
炽热的
,
2023-01-18 21:51:06
,
所有人可见
,
阅读 49
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long i64;
const int N = 110;
int n, m, k;
int s[N][N];
int main() {
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= n; i ++ )
for (int j = 1; j <= m; j ++ ) {
scanf("%d", &s[i][j]);
s[i][j] += s[i - 1][j];
}
int res = 1e9;
for (int x = 1; x <= n; x ++ )
for (int y = x; y <= n; y ++ )
for (int i = 1, j = 1, v = 0; i <= m; i ++ ) {
v += s[y][i] - s[x - 1][i];
while (j < i && v - (s[y][j] - s[x - 1][j]) >= k) v -= (s[y][j] - s[x - 1][j]), j ++ ;
if (v >= k) res = min(res, (y - x + 1) * (i - j + 1));
}
if (res == 1e9) res = -1;
printf("%d\n", res);
return 0;
}