# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
491208 | 2021-11-30T18:08:31 Z | Vladikus004 | 호화 벙커 (IZhO13_burrow) | C++14 | 2 ms | 332 KB |
#include <bits/stdc++.h> #define mp make_pair #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define inf 2e9 #define ff first #define ss second #define pb push_back #define sz(x) (int)x.size() #define int long long using namespace std; typedef long long ll; typedef pair <int, int> pii; const int N = 1000 + 3; int n, m, k, a[N][N], h[N][N]; int check(int x) { for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) h[i][j] = (a[i][j] >= x); for (int i = 1; i < n; i++) for (int j = 0; j < m; j++) if (h[i][j]) h[i][j] += h[i - 1][j]; int mx = 0; for (int i = 0; i < n; i++) { stack <int> st; for (int j = 0; j < m; j++) { while (sz(st) && h[i][st.top()] >= h[i][j]) st.pop(); int ws; if (sz(st)) ws = st.top(); else ws = -1; st.push(j); mx = max(mx, h[i][j] * (j - ws)); } while (sz(st)) st.pop(); for (int j = m - 1; j >= 0; j--) { while (sz(st) && h[i][st.top()] >= h[i][j]) st.pop(); int ws; if (sz(st)) ws = st.top(); else ws = m; st.push(j); mx = max(mx, h[i][j] * (ws - j)); } } if (mx < k) return 0; return mx; } void solve() { cin >> n >> m >> k; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { cin >> a[i][j]; } } int l = 1, r = 1000000000 + 7; while (l < r) { int mid = (l + r) / 2; if (check(mid)) l = mid + 1; else r = mid; } cout << l - 1 << " " << check(l - 1); } int32_t main(){ ios_base::sync_with_stdio(false); cin.tie(0); freopen("burrow.in", "r", stdin); freopen("burrow.out", "w", stdout); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 332 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |