# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1175843 | nightingale | 삶의 질 (IOI10_quality) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int r,c,h,w;
int best = LLONG_MAX;
cin >> r >> c >> h >> w;
vector<vector<int>> city(r,vector<int>(c));
for(int i=0;i<r;i++){
for(int j=0;j<c;j++){
cin >> city[i][j];
}
}
for(int i=0;i<r-h+1;i++){
for(int j=0;j<c-w+1;j++){
vector<int> meh;
for(int k=0;k<h;k++){
for(int m=0;m<w;m++){
meh.push_back(city[i+k][j+m]);
}
}
sort(meh.begin(),meh.end());
if(meh[((meh.size()+1)/2)-1]<best) best = meh[((meh.size()+1)/2)-1];
}
}
cout << best;
}