# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
933108 | sleepntsheep | Luxury burrow (IZhO13_burrow) | C11 | 450 ms | 18000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<stdio.h>
int hi(int a,int b){return a>b?a:b;}
int sz,n,m,k,a[1002][1002],b[1002][1002],st[1002],top,nl[1002],pl[1002];
int ok(int lo)
{
for(int i=0;i++<n;)for(int j=0;j++<m;)b[i][j]=a[i][j]>=lo;
for(int i=0;i++<n;)for(int j=0;j++<m;)
if(b[i][j])b[i][j]+=b[i-1][j];
int hisz=0;
for(int i=0;i++<n;)
{
int*h=b[i];
for(int j=0;j++<m;)
{
while(top&&h[j]<h[st[top]])nl[st[top--]]=j;
st[++top]=j;
}
while(top)nl[st[top--]]=m+1;
for(int j=m;j>=1;--j)
{
while(top&&h[j]<h[st[top]])pl[st[top--]]=j;
st[++top]=j;
}
while(top)pl[st[top--]]=0;
for(int j=0;j++<m;)
hisz=hi(hisz,h[j]*(nl[j]-pl[j]-1));
}
return hisz>=k?sz=hisz,1:0;
}
int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=0;i++<n;)for(int j=0;j++<m;)scanf("%d",a[i]+j);
ok(10);
int l=0,r=1e9;
while(l<=r){
int y=(l+r)/2;
if(ok(y))l=y+1;else r=y-1;
}
printf("%d %d",l-1,sz);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |