Submission #537992

#TimeUsernameProblemLanguageResultExecution timeMemory
537992GioChkhaidzeLuxury burrow (IZhO13_burrow)C++14
100 / 100
394 ms17932 KiB
#include <bits/stdc++.h> #define f first #define s second using namespace std; const int N = 1003; int n, m, k, ans_c, ans_a, a[N][N], b[N][N]; bool check(int x) { for (int i = n; i >= 1; --i) for (int j = m; j >= 1; --j) if (a[i][j] >= x) b[i][j] = b[i + 1][j] + 1; else b[i][j] = 0; int area = 0; deque < pair < int , int > > dq; for (int i = 1; i <= n; ++i) { for (int j = m; j >= 1; --j) { int id = j; while (dq.size() && dq.back().f >= b[i][j]) { area = max(area, dq.back().f * (dq.back().s - j)); id = dq.back().s; dq.pop_back(); } area = max(area, b[i][j] * (id - j + 1)); dq.push_back({b[i][j], id}); } while (dq.size()) { area = max(area, dq.back().f * dq.back().s); dq.pop_back(); } } if (area >= k) { ans_c = x; ans_a = area; return true; } return false; } main () { ios::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); 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, mid; while (l <= r) { mid = ((l + r) >> 1); if (check(mid)) l = mid + 1; else r = mid - 1; } cout << ans_c << " " << ans_a << "\n"; }

Compilation message (stderr)

burrow.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main () {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...