/* ID: espr1t TASK: KEYWORDS: CONTEST: CodeIT Round 4 */ #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; FILE *in; FILE *out; const int MAX = 1024; int n, m, k; int a[MAX][MAX]; int main(void) { in = stdin; out = stdout; in = fopen("minark.in", "rt"); out = fopen("minark.out", "wt"); fscanf(in, "%d %d %d", &n, &m, &k); for (int i = 0; i < n; i++) { for (int c = 0; c < m; c++) { fscanf(in, "%d", &a[i][c]); } } int ans = -1; for (int srow = 0; srow < n; srow++) { for (int scol = 0; scol < m; scol++) { for (int erow = srow; erow < n; erow++) { for (int ecol = scol; ecol < m; ecol++) { int sum = 0; for (int row = srow; row <= erow; row++) { for (int col = scol; col <= ecol; col++) { sum += a[row][col]; } } if (k <= sum) { if (ans == -1) ans = ((erow - srow + 1) * (ecol - scol + 1)); else ans = min(ans, (erow - srow + 1) * (ecol - scol + 1)); } } } } } fprintf(out, "%d\n", ans); return 0; }