# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168404 | 2019-12-13T03:04:05 Z | abil | Luxury burrow (IZhO13_burrow) | C++14 | 727 ms | 14072 KB |
#include <bits/stdc++.h> #define fr first #define sc second #define pb push_bacak #define mk make_pair #define all(s) s.begin(),s.end() //#define int long long using namespace std; const int N = (1e6 + 12); const int mod = (1e9 + 7); const int INF = (0x3f3f3f3f); int a[1012][1012], b[1012], n, m, l[1012], r[1012]; int check(int x){ for(int i = 1;i <= m; i++){ b[i] = 0; } int res = 0; stack <int > st; for(int i = 1;i <= n; i++){ for(int j = 1;j <= m; j++){ if(a[i][j] >= x){ b[j]++; } else{ b[j] = 0; } } for(int j = 1;j <= m; j++){ while(!st.empty() && b[st.top()] >= b[j]){ st.pop(); } if(!st.empty()){ l[j] = st.top() + 1; } else{ l[j] = 1; } st.push(j); } while(!st.empty()){ st.pop(); } for(int j = m;j >= 1; j--){ while(!st.empty() && b[st.top()] >= b[j]){ st.pop(); } if(!st.empty()){ r[j] = st.top() - 1; } else{ r[j] = m; } st.push(j); } while(!st.empty()){ st.pop(); } for(int j = 1;j <= m; j++){ res = max(res, (r[j] - l[j] + 1) * b[j]); } } return res; } main() { int k; 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]); } } //cout << check(2); int l = 0, r = INF; while(r - l > 1){ int mid = (r + l) >> 1; if(check(mid) >= k){ l = mid; } else{ r = mid; } } if(check(r) >= k){ l = r; } printf("%d %d", l, check(l)); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 380 KB | Output is correct |
6 | Correct | 3 ms | 504 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 8 ms | 760 KB | Output is correct |
9 | Correct | 14 ms | 1272 KB | Output is correct |
10 | Correct | 33 ms | 1400 KB | Output is correct |
11 | Correct | 57 ms | 1912 KB | Output is correct |
12 | Correct | 33 ms | 2508 KB | Output is correct |
13 | Correct | 43 ms | 1244 KB | Output is correct |
14 | Correct | 99 ms | 2560 KB | Output is correct |
15 | Correct | 107 ms | 2740 KB | Output is correct |
16 | Correct | 111 ms | 3060 KB | Output is correct |
17 | Correct | 118 ms | 2808 KB | Output is correct |
18 | Correct | 286 ms | 5492 KB | Output is correct |
19 | Correct | 324 ms | 4984 KB | Output is correct |
20 | Correct | 650 ms | 9172 KB | Output is correct |
21 | Correct | 568 ms | 10316 KB | Output is correct |
22 | Correct | 706 ms | 14072 KB | Output is correct |
23 | Correct | 727 ms | 13984 KB | Output is correct |
24 | Correct | 513 ms | 7132 KB | Output is correct |
25 | Correct | 520 ms | 7252 KB | Output is correct |