# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
441223 | 2021-07-04T17:23:11 Z | parsabahrami | Luxury burrow (IZhO13_burrow) | C++17 | 566 ms | 17952 KB |
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int, int> pii; #define SZ(x) (int) x.size() #define F first #define S second const int N = 1e3 + 10, MOD = 1e9 + 7; int A[N][N], L[N], R[N], up[N][N], n, k, m; int get(int x) { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (A[i][j] < x) { up[i][j] = 0; continue; } if (A[i - 1][j] >= x) up[i][j] = up[i - 1][j] + 1; else up[i][j] = 1; } } int ret = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { for (L[j] = j - 1; L[j] && up[i][L[j]] >= up[i][j]; L[j] = L[L[j]]); } for (int j = m; j; j--) { for (R[j] = j + 1; R[j] <= m && up[i][R[j]] >= up[i][j]; R[j] = R[R[j]]); } for (int j = 1; j <= m; j++) { ret = max(ret, up[i][j] * (R[j] - L[j] - 1)); } } return ret; } int main() { scanf("%d%d%d", &n, &m, &k); for (int i = 1; i <= n; i++) for (int j = 1; j <= m; j++) scanf("%d", &A[i][j]); int l = 0, r = MOD; while (r - l > 1) { int md = (l + r) >> 1; if (get(md) < k) r = md; else l = md; } printf("%d %d\n", l, get(l)); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 1 ms | 460 KB | Output is correct |
5 | Correct | 1 ms | 460 KB | Output is correct |
6 | Correct | 1 ms | 588 KB | Output is correct |
7 | Correct | 1 ms | 332 KB | Output is correct |
8 | Correct | 6 ms | 1100 KB | Output is correct |
9 | Correct | 9 ms | 1996 KB | Output is correct |
10 | Correct | 26 ms | 2124 KB | Output is correct |
11 | Correct | 45 ms | 3012 KB | Output is correct |
12 | Correct | 26 ms | 4300 KB | Output is correct |
13 | Correct | 33 ms | 1484 KB | Output is correct |
14 | Correct | 81 ms | 4044 KB | Output is correct |
15 | Correct | 87 ms | 4044 KB | Output is correct |
16 | Correct | 84 ms | 4556 KB | Output is correct |
17 | Correct | 94 ms | 4668 KB | Output is correct |
18 | Correct | 220 ms | 7824 KB | Output is correct |
19 | Correct | 262 ms | 7700 KB | Output is correct |
20 | Correct | 496 ms | 12192 KB | Output is correct |
21 | Correct | 424 ms | 13764 KB | Output is correct |
22 | Correct | 532 ms | 17952 KB | Output is correct |
23 | Correct | 566 ms | 17872 KB | Output is correct |
24 | Correct | 389 ms | 10692 KB | Output is correct |
25 | Correct | 408 ms | 11076 KB | Output is correct |