# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5398 | gs12117 | Luxury burrow (IZhO13_burrow) | C++98 | 648 ms | 5088 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.
#include<stdio.h>
int n,m,p;
int a[1010][1010];
int b[1010];
int stk[1010];
int sp;
int lend[1010];
int rend[1010];
int f(int x){
int i,j,ans;
for(i=0;i<m;i++){
b[i]=0;
}
ans=0;
for(i=0;i<n;i++){
for(j=0;j<m;j++){
if(a[i][j]>=x){
b[j]++;
}
else b[j]=0;
}
stk[0]=-1;
sp=1;
for(j=0;j<m;j++){
while(sp!=1&&b[stk[sp-1]]>=b[j])sp--;
lend[j]=stk[sp-1];
stk[sp]=j;
sp++;
}
stk[0]=m;
sp=1;
for(j=m-1;j>=0;j--){
while(sp!=1&&b[stk[sp-1]]>=b[j])sp--;
rend[j]=stk[sp-1];
stk[sp]=j;
sp++;
}
for(j=0;j<m;j++){
if(ans<b[j]*(rend[j]-lend[j]-1))ans=b[j]*(rend[j]-lend[j]-1);
}
}
return ans;
}
int main(){
int i,j;
scanf("%d%d%d",&n,&m,&p);
for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf("%d",&a[i][j]);
}
}
j=-1;
for(i=30;i>=0;i--){
j+=1<<i;
if(f(j)<p)j-=1<<i;
}
printf("%d %d",j,f(j));
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |