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>
#include "quality.h"
int sum[3010][3010];
bool ok(int n,int m,int l,int c,int a[3001][3001],int val)
{
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
if(a[i-1][j-1]<=val)
sum[i][j]=1+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
else
sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
for(int i=l;i<=n;++i)
for(int j=c;j<=m;++j)
if(sum[i][j]-sum[i-l][j]-sum[i][j-c]+sum[i-l][j-c]>l*c/2)
return true;
return false;
}
int rectangle(int n,int m,int l,int c,int a[3001][3001])
{
long long b=1,e=n*m;
while(b<=e)
{
if(ok(n,m,l,c,a,(b+e)/2))
e=(b+e)/2-1;
else
b=(b+e)/2+1;
}
return b;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |