# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1175713 | skibidoi | Quality Of Living (IOI10_quality) | C++17 | 0 ms | 0 KiB |
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long int;
int rectangle(int r, int c, int h, int w, vector<vector<int>>& q) {
int ans = INT_MAX;
vector<int> cnt;
for (int i = 0; i <= r - h; i++) {
for (int j = 0; j <= c - w; j++) {
cnt.clear();
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 wtf = cnt[(h * w) / 2];
ans = min(ans, wtf);
}
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int r, c, h, w;
cin >> r >> c >> h >> w;
vector<vector<int>> q(r, vector<int>(c));
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
cin >> q[i][j];
}
}
cout << rectangle(r, c, h, w, q) << endl;
}