#include <bits/stdc++.h>
using namespace std;
int rectangle(int r, int c, int h, int w, int q[3001][3001]) {
int ans = INT_MAX;
vector<vector<int>> prefix_sum(r + 1, vector<int>(c + 1, 0));
for (int i = 1; i <= r; i++) {
for (int j = 1; j <= c; j++) {
prefix_sum[i][j] = q[i - 1][j - 1] + prefix_sum[i - 1][j] + prefix_sum[i][j - 1] - prefix_sum[i - 1][j - 1];
}
}
for (int i = 0; i <= r - h; i++) {
for (int j = 0; j <= c - w; j++) {
vector<int> cnt;
for (int x = 0; x < h; x++) {
for (int y = 0; y < w; y++) {
cnt.push_back(q[i + x][j + y]);
}
}
sort(cnt.begin(), cnt.end());
int median = cnt[(h * w) / 2];
ans = min(ans, median);
}
}
return ans;
}
# | 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... |