This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "quality.h"
#define N 3000
#define M 3000
int solve(int aa[][3001], int n, int m, int k, int l, int a) {
static int aa_[N + 1][M + 1];
int i, j;
for (i = 0; i < n; i++)
for (j = 0; j < m; j++)
aa_[i][j] = aa[i][j] <= a ? 1 : -1;
for (i = 0; i < n; i++)
for (j = m - 1; j >= 0; j--)
aa_[i][j] += aa_[i][j + 1];
for (j = 0; j < m; j++)
for (i = n - 1; i >= 0; i--)
aa_[i][j] += aa_[i + 1][j];
for (i = 0; i + k <= n; i++)
for (j = 0; j + l <= m; j++)
if (aa_[i][j] - aa_[i][j + l] - aa_[i + k][j] + aa_[i + k][j + l] > 0)
return 1;
return 0;
}
int rectangle(int n, int m, int k, int l, int aa[][3001]) {
int lower = 0, upper = n * m;
while (upper - lower > 1) {
int a = (lower + upper) / 2;
if (solve(aa, n, m, k, l, a))
upper = a;
else
lower = a;
}
return upper;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |