Submission #49189

# Submission time Handle Problem Language Result Execution time Memory
49189 2018-05-23T14:13:35 Z tmwilliamlin168 Luxury burrow (IZhO13_burrow) C++14
100 / 100
550 ms 54720 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN=1000;
int n, m, k, a[mxN][mxN], lb=1, rb=1e9, mb, a2, a3, b[mxN+1][mxN], l[mxN], r[mxN];

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m >> k;
	for(int i=0; i<n; ++i)
		for(int j=0; j<m; ++j)
			cin >> a[i][j];
	while(lb<=rb) {
		mb=(lb+rb)/2, a3=0;
		for(int i=n-1; i>=0; --i)
			for(int j=0; j<m; ++j)
				b[i][j]=a[i][j]<mb?0:b[i+1][j]+1;
		for(int i=0; i<n; ++i) {
			for(int j=0; j<m; ++j) {
				l[j]=j-1;
				while(l[j]>=0&&b[i][l[j]]>=b[i][j])
					l[j]=l[l[j]];
			}
			for(int j=m-1; j>=0; --j) {
				r[j]=j+1;
				while(r[j]<m&&b[i][r[j]]>=b[i][j])
					r[j]=r[r[j]];
				a3=max(b[i][j]*(r[j]-l[j]-1), a3);
			}
		}
		if(a3>=k) {
			lb=mb+1;
			a2=a3;
		} else
			rb=mb-1;
	}
	cout << rb << " " << a2;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 628 KB Output is correct
3 Correct 3 ms 684 KB Output is correct
4 Correct 3 ms 740 KB Output is correct
5 Correct 3 ms 904 KB Output is correct
6 Correct 4 ms 1056 KB Output is correct
7 Correct 3 ms 1056 KB Output is correct
8 Correct 7 ms 1532 KB Output is correct
9 Correct 11 ms 2460 KB Output is correct
10 Correct 26 ms 2908 KB Output is correct
11 Correct 46 ms 3844 KB Output is correct
12 Correct 25 ms 5916 KB Output is correct
13 Correct 34 ms 5916 KB Output is correct
14 Correct 88 ms 6396 KB Output is correct
15 Correct 78 ms 6852 KB Output is correct
16 Correct 106 ms 7948 KB Output is correct
17 Correct 85 ms 9284 KB Output is correct
18 Correct 206 ms 12892 KB Output is correct
19 Correct 215 ms 15392 KB Output is correct
20 Correct 527 ms 21924 KB Output is correct
21 Correct 391 ms 28956 KB Output is correct
22 Correct 550 ms 39352 KB Output is correct
23 Correct 533 ms 48984 KB Output is correct
24 Correct 361 ms 51472 KB Output is correct
25 Correct 370 ms 54720 KB Output is correct