# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
75964 | Vardanyan | Luxury burrow (IZhO13_burrow) | C++14 | 2051 ms | 4128 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;
const int N = 1005;
int t[N][4*N];
int a[N][N];
void build(int row,int v,int l,int r){
if(l == r){
t[row][v] = a[row][l];
return;
}
int m = (l+r)/2;
build(row,v*2,l,m);
build(row,v*2+1,m+1,r);
t[row][v] = min(t[row][v*2],t[row][v*2+1]);
}
int query(int row,int v,int s,int e,int l,int r){
if(l>r) return 1000*1000*1000+5;
if(s == l && e == r) return t[row][v];
int m = (s+e)/2;
return min(query(row,v*2,s,m,l,min(m,r)),query(row,v*2+1,m+1,e,max(l,m+1),r));
}
int main(){
int n,m,k;
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]);
build(i,1,1,m);
}
int mxans = 0;
int mxs = k;
for(int i = 1;i<=n;i++){
for(int j = 1;j<=m;j++){
if(a[i][j]<mxans) continue;
for(int jj = j;jj<=m;jj++){
/*if(j == 1 && jj == m){
cout<<0<<endl;
}*/
int mnnow = 1000*1000*1000+5;
bool f = false;
for(int ii = i;ii<=n;ii++){
mnnow = min(mnnow,query(ii,1,1,m,j,jj));
if(mnnow<mxans) break;
/*if(mnnow<mxans){
f = true;
continue;
// break;
}*/
int s = (jj-j+1)*(ii-i+1);
if(mnnow == mxans){
if(s>=mxs){
mxs = s;
}
}
if(mnnow>mxans){
if(s>=k){
mxs = s;
mxans = mnnow;
}
}
}
if(f) break;
}
}
}
cout<<mxans<<" "<<mxs<<endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |