#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
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]);
~~~~~^~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
436 KB |
Output is correct |
3 |
Correct |
2 ms |
436 KB |
Output is correct |
4 |
Correct |
3 ms |
544 KB |
Output is correct |
5 |
Correct |
6 ms |
764 KB |
Output is correct |
6 |
Correct |
4 ms |
856 KB |
Output is correct |
7 |
Correct |
14 ms |
856 KB |
Output is correct |
8 |
Correct |
80 ms |
1572 KB |
Output is correct |
9 |
Correct |
1383 ms |
2632 KB |
Output is correct |
10 |
Correct |
175 ms |
3032 KB |
Output is correct |
11 |
Execution timed out |
2051 ms |
4128 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |