Submission #4765

# Submission time Handle Problem Language Result Execution time Memory
4765 2014-01-01T08:42:37 Z ainta Luxury burrow (IZhO13_burrow) C++
100 / 100
384 ms 9068 KB
#include<stdio.h>
#define N_ 1010
int n, m, k, w[N_][N_], C[N_][N_], i, j, B, E, M, p[N_], st[N_][2], top, R, t, x, Res[2];
int main()
{
	scanf("%d%d%d", &n, &m, &k);
	B = 1;
	for (i = 1; i <= n; i++){
		for (j = 1; j <= m; j++){
			scanf("%d", &w[i][j]);
			if (E < w[i][j])E = w[i][j];
		}
	}
	while (B <= E){
		M = (B + E + 1) >> 1;
		R = 0;
		for (i = 1; i <= m; i++)p[i] = 0;
		for (i = 1; i <= n; i++){
			top = 0;
			for (j = 1; j <= m + 1; j++){
				if (w[i][j] < M)p[j] = i;
				x = j;
				while (top && i - p[j] <= st[top][0]){
					t = st[top][0] * (j - st[top][1]);
					if (R < t)R = t;
					x = st[top][1]; top--;
				}
				if(p[j]!=i)st[++top][0] = i - p[j], st[top][1] = x;
			}
		}
		if (R >= k){
			Res[0] = M, Res[1] = R;
			B = M + 1;
		}
		else E = M - 1;
	}
	printf("%d %d\n", Res[0], Res[1]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9068 KB Output is correct
2 Correct 0 ms 9068 KB Output is correct
3 Correct 0 ms 9068 KB Output is correct
4 Correct 0 ms 9068 KB Output is correct
5 Correct 0 ms 9068 KB Output is correct
6 Correct 0 ms 9068 KB Output is correct
7 Correct 0 ms 9068 KB Output is correct
8 Correct 0 ms 9068 KB Output is correct
9 Correct 4 ms 9068 KB Output is correct
10 Correct 12 ms 9068 KB Output is correct
11 Correct 24 ms 9068 KB Output is correct
12 Correct 8 ms 9068 KB Output is correct
13 Correct 12 ms 9068 KB Output is correct
14 Correct 36 ms 9068 KB Output is correct
15 Correct 36 ms 9068 KB Output is correct
16 Correct 48 ms 9068 KB Output is correct
17 Correct 28 ms 9068 KB Output is correct
18 Correct 132 ms 9068 KB Output is correct
19 Correct 96 ms 9068 KB Output is correct
20 Correct 292 ms 9068 KB Output is correct
21 Correct 260 ms 9068 KB Output is correct
22 Correct 384 ms 9068 KB Output is correct
23 Correct 380 ms 9068 KB Output is correct
24 Correct 168 ms 9068 KB Output is correct
25 Correct 156 ms 9068 KB Output is correct