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 "bits/stdc++.h"
#include "quality.h"
using namespace std;
int rectangle(int R, int C, int H, int W, int Q[3001][3001]) {
long long arr[R+1][C+1];
memset(arr, 0, sizeof arr);
int l = 1, r = R*C;
while (l < r) {
int mid = (l+r)/2;
for (int i = 0; i < R; i++) {
for (int j = 0; j < C; j++) {
if (Q[i][j] <= mid)
arr[i+1][j+1] = 1;
else
arr[i+1][j+1] = 0;
arr[i+1][j+1] += arr[i+1][j] + arr[i][j+1] - arr[i][j];
}
}
bool valid = false;
for (int i = 1; i + H - 1<= R; i++) {
for (int j = 1; j + W - 1<= C; j++) {
if (arr[i+H-1][j+W-1] - arr[i+H-1][j-1] - arr[i-1][j+W-1] + arr[i-1][j-1] > H*W/2) {
valid = true;
break;
}
}
}
if (valid)
r = mid;
else
l = mid+1;
}
return r;
}
# | 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... |