#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++){
for(int jj = j;jj<=m;jj++){
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){
f = true;
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
burrow.cpp: In function 'int main()':
burrow.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d",&n,&m,&k);
~~~~~^~~~~~~~~~~~~~~~~~~
burrow.cpp:26:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
for(int j = 1;j<=m;j++) scanf("%d",&a[i][j]);
~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |