# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
47579 | dqhungdl | Luxury burrow (IZhO13_burrow) | C++17 | 569 ms | 4732 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 <bits/stdc++.h>
using namespace std;
int m,n,k,L[1005],R[1005],h[1005],a[1005][1005];
int Check(int lim)
{
for(int i=1;i<=n;i++)
h[i]=0;
int maxn=0;
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
if(a[i][j]>=lim)
h[j]++;
else
h[j]=0;
for(int j=1;j<=n;j++)
{
L[j]=j;
int tmp=j-1;
while(tmp>0&&h[j]<=h[tmp])
{
L[j]=L[tmp];
tmp=L[tmp]-1;
}
}
for(int j=n;j>=1;j--)
{
R[j]=j;
int tmp=j+1;
while(tmp<=n&&h[j]<=h[tmp])
{
R[j]=R[tmp];
tmp=R[tmp]+1;
}
}
for(int j=1;j<=n;j++)
maxn=max(maxn,h[j]*(R[j]-L[j]+1));
}
return maxn;
}
int main()
{
ios_base::sync_with_stdio(false);
//freopen("TEST.INP","r",stdin);
//freopen("TEST.OUT","w",stdout);
cin>>m>>n>>k;
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
cin>>a[i][j];
int area,rs,l=1,r=1e9;
while(l<=r)
{
int mid=(l+r)/2;
int tmp=Check(mid);
if(tmp>=k)
{
area=tmp;
rs=mid;
l=mid+1;
}
else
r=mid-1;
}
cout<<rs<<' '<<area;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |