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>
using namespace std;
int ps[3001][3001];
int sum(int x1, int x2, int y1, int y2){
return ps[x2 + 1][y2 + 1] - ps[x2 + 1][y1] - ps[x1][y2 + 1] + ps[x1][y1];
}
bool ok(int R, int C, int H, int W, int Q[3001][3001], int x){
for(int i = 0; i < R; i++){
for(int j = 0; j < C; j++){
ps[i + 1][j + 1] = ps[i + 1][j] + ps[i][j + 1] - ps[i][j] + (Q[i][j] <= x);
}
}
for(int i = 0; i <= R - H; i++){
for(int j = 0; j <= C - W; j++){
if(sum(i, i + H - 1, j, j + W - 1) >= (H * W + 1) / 2){
return true;
}
}
}
return false;
}
int rectangle(int R, int C, int H, int W, int Q[3001][3001]){
int lo = 1, hi = R * C;
while(lo != hi){
int mid = (lo + hi) / 2;
if(ok(R, C, H, W, Q, mid)){
hi = mid;
}else{
lo = mid + 1;
}
}
return lo;
}
# | 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... |