# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
388287 | ritul_kr_singh | 호화 벙커 (IZhO13_burrow) | C++17 | 416 ms | 17840 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp << ' ' <<
#define nl << '\n'
int n, m, k, g[1001][1001], a[1002];
int maxArea(){
int res = 0;
vector<int> st = {0};
for(int j=1; j<=m+1; ++j){
while(!st.empty() and a[st.back()] > a[j]){
int y = a[st.back()]; st.pop_back();
res = max(res, (j-st.back()-1)*y);
}
st.push_back(j);
}
return res;
}
int best(int x){
fill(a, a+m+2, 0LL);
int res = 0;
for(int i=1; i<=n; ++i){
for(int j=1; j<=m; ++j)
a[j] += g[i][j] >= x ? 1 : -a[j];
res = max(res, maxArea());
}
return res;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> k;
for(int i=1; i<=n; ++i)
for(int j=1; j<=m; ++j)
cin >> g[i][j];
int low = 0, high = 1e9;
while(low<high){
int mid = (low+high)/2;
if(best(mid+1)>=k) low = mid+1;
else high = mid;
}
cout << low sp best(low);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |