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