#include <bits/stdc++.h>
using namespace std;
const int N=1005;
int v[N][N];
int a[N];
int cal(){
vector<int> st;
int ans=0;
for(int i=0;i<N;i++){
while(st.size()&&a[st.back()]>a[i]){
ans=max(ans,(i-st.back())*a[st.back()]);
st.pop_back();
}
st.push_back(i);
}
return ans;
}
int solve(int m){
int ans=0;
for(int j=0;j<N;j++){
a[j]=0;
}
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(v[i][j]>=m){
a[j]++;
}
else{
a[j]=0;
}
}
ans=max(ans,cal());
}
return ans;
}
int32_t main() {
int n,m,k;cin>>n>>m>>k;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
cin>>v[i][j];
}
}
int l=0,r=1e9+5;
while(r-l>1){
int mi=(l+r)>>1;
if(solve(mi)>=k){
l=mi;
}
else{
r=mi;
}
}
cout<<l<<' '<<solve(l)<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
456 KB |
Output is correct |
2 |
Correct |
105 ms |
344 KB |
Output is correct |
3 |
Correct |
109 ms |
344 KB |
Output is correct |
4 |
Correct |
109 ms |
544 KB |
Output is correct |
5 |
Incorrect |
110 ms |
344 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |