# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092452 | juicy | Luxury burrow (IZhO13_burrow) | C++17 | 362 ms | 17996 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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 1005;
int n, m, k;
int a[N][N], up[N][N], l[N];
int qry(int md) {
int area = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
up[i][j] = a[i][j] >= md ? up[i - 1][j] + 1 : 0;
}
}
for (int i = 1; i <= n; ++i) {
vector<int> st;
for (int j = 1; j <= m; ++j) {
while (st.size() && up[i][st.back()] >= up[i][j]) {
st.pop_back();
}
l[j] = st.size() ? st.back() : 0;
st.push_back(j);
}
vector<int>().swap(st);
for (int j = m; j; --j) {
while (st.size() && up[i][st.back()] >= up[i][j]) {
st.pop_back();
}
int r = st.size() ? st.back() - 1 : m;
area = max(area, up[i][j] * (r - l[j]));
st.push_back(j);
}
}
return area;
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
cin >> a[i][j];
}
}
int l = 1, r = 1e9, p = r;
while (l <= r) {
int md = (l + r) / 2;
if (qry(md) >= k) {
p = md;
l = md + 1;
} else {
r = md - 1;
}
}
cout << p << " " << qry(p);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |