#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i < (n); i++)
#define f1(i, n) for(int i(1); i <= n; i++)
using namespace std;
typedef long long ll;
const int N = 402;
int m, n, a[N][N], k, ma[N], now = 0;
int res = 0;
int calc(int k1, int k2, int cur){
f1(i, n){
int j = i;
for(j; j <= n; j++){
if(ma[j] >= cur) continue;
else break;
}
--j;
res = max(res, (k2 - k1 + 1)*(j - i + 1));
i = j + 1;
}
return res;
}
bool check(int cur){
res = 0;
f1(i, m){
f1(j, n) ma[j] = 1e9 + 100;
for(int j = i; j <= m; j++){
for(int x = 1; x <= n; x++){
ma[x] = min(ma[x], a[j][x]);
}
res = max(res, calc(i, j, cur));
}
}
if(res >= k) now = res;
return res >= k;
}
int main(){
ios_base::sync_with_stdio(0);
cin >> m >> n >> k;
f1(i, m) f1(j, n) cin >> a[i][j];
int l = 1, r = 1e9 + 2, ans = 1;
while(l <= r){
int mid = (l + r)/2;
if(check(mid)) l = mid + 1, ans = mid;
else r = mid - 1;
}
cout << ans << " " << now;
}
Compilation message
burrow.cpp: In function 'int calc(int, int, int)':
burrow.cpp:15:14: warning: statement has no effect [-Wunused-value]
for(j; j <= n; j++){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
452 KB |
Output is correct |
3 |
Correct |
2 ms |
452 KB |
Output is correct |
4 |
Correct |
2 ms |
452 KB |
Output is correct |
5 |
Correct |
3 ms |
452 KB |
Output is correct |
6 |
Correct |
5 ms |
456 KB |
Output is correct |
7 |
Correct |
2 ms |
456 KB |
Output is correct |
8 |
Correct |
62 ms |
796 KB |
Output is correct |
9 |
Correct |
174 ms |
796 KB |
Output is correct |
10 |
Correct |
313 ms |
844 KB |
Output is correct |
11 |
Correct |
704 ms |
1024 KB |
Output is correct |
12 |
Runtime error |
14 ms |
1840 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
13 |
Halted |
0 ms |
0 KB |
- |