# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
378463 | ijxjdjd | 호화 벙커 (IZhO13_burrow) | C++14 | 545 ms | 15108 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |