# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
378463 | ijxjdjd | Luxury burrow (IZhO13_burrow) | C++14 | 545 ms | 15108 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>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
const int MAXN = 1000;
bool active[MAXN][MAXN];
int board[MAXN][MAXN];
int histoArea(vector<int>& hist) {
stack<pair<int, int>> st;
int mx = 0;
FR(i, hist.size()) {
while (st.size() && hist[st.top().first] >= hist[i]) {
mx = max(hist[st.top().first] * (i-st.top().second-1), mx);
st.pop();
}
st.push({i, (st.size() ? st.top().first : -1)});
}
return mx;
}
int maxArea(int N, int M) {
vector<int> cur(M+1);
cur[M] = -1;
int res = 0;
FR(i, N) {
FR(j, M) {
if (active[i][j]) {
cur[j]++;
}
else {
cur[j] = 0;
}
}
res = max(res, histoArea(cur));
}
return res;
}
int findUp(int N, int M, int b) {
memset(active, 0, sizeof(active));
FR(i, N) {
FR(j, M) {
if (board[i][j] >= b) {
active[i][j] = true;
}
}
}
return maxArea(N, M);
}
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
int N, M, K;
cin >> N >> M >> K;
FR(i, N) {
FR(j, M) {
cin >> board[i][j];
}
}
int low = 0;
int high = (int)(1e9) + 5;
int cnt = 0;
while (low < high) {
int mid = (low + high+1)/2;
int res = findUp(N, M, mid);
if (res >= K) {
low = mid;
cnt = res;
}
else {
high = mid-1;
}
}
cout << low << " " << findUp(N, M, low) << '\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |