# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
204146 | Kalam | Luxury burrow (IZhO13_burrow) | C++11 | 587 ms | 18568 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// KALAM
# include<bits/stdc++.h>
using namespace std;
const int N = 1000 + 77;
int n , m , k , a[N][N] , b[N][N] , c[N] , L[N] , R[N];
inline int Solve() {
int res = 0;
for(int i = 1;i <= m;++ i) {
L[i] = i - 1;
while(c[L[i]] >= c[i] && L[i] > 0)
L[i] = L[L[i]];
}
for(int i = m;i > 0;-- i) {
R[i] = i + 1;
while(c[R[i]] >= c[i] && R[i] <= m)
R[i] = R[R[i]];
res = max(res , (R[i] - L[i] - 1) * c[i]);
}
return res;
}
inline int Check(int t) {
int res = 0;
for(int i = 1;i <= n;++ i) {
for(int j = 1;j <= m;++ j)
b[i][j] = (a[i][j] >= t ? 1 + b[i - 1][j] : 0);
for(int j = 1;j <= m;++ j)
c[j] = b[i][j];
res = max(res , Solve());
}
return res;
}
int main() {
scanf("%d %d %d" , & n , & m , & k);
for(int i = 1;i <= n;++ i)
for(int j = 1;j <= m;++ j)
scanf("%d" , & a[i][j]);
int le = 1 , ri = 1000000001;
while(ri - le > 1) {
int mid = ((le + ri) >> 1);
if(Check(mid) >= k)
le = mid;
else
ri = mid;
}
printf("%d %d\n" , le , Check(le));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |