/*
Problem link
Type: Data Structure - 2D Segment tree/Quad tree.
Algorithm:
1 /*
2 Problem link
3 Type: Data structure - Binary index (Fenwick) tree
4 Algorithm:
1 /*
2 Problem link
3 Type: Data structure - link list
4 Algorithm:
/*
Problem link
Type: Data structure
*/
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <cstdlib>
6 #include <vector>
7 #include <queue>
8 #include <stack>
/*
Problem link
Type: Adhoc - greedy, Data structure - priority queue
*/
1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <vector>
6 #include <queue>
//============================================================================
// Name : 11235.cpp
// Author : Mr Tu
// Version :
// Copyright : Your copyright notice
// Description : Uva 11235 - Frequent values in C++, Ansi-style
// Problem link
// Algorithm: Data structure - Segment tree
//============================================================================
/*
Problem link
Type: Graph
Algorithm: Kruskal, minimum spanning tree, using priority queue
*/
#include <iostream>
#include <queue>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <fstream>
using namespace std;
const int maxn = 200010;
/*
Problem link Type: DP, data structure Algorithm: I use the stack in the problem, with this I can solve it in O(n^2) Let h[i][j] be the height of the consecutive comlumn of 0 at (i,j) Let l[i][j] is the index left most element of (i,j) that from h[i][l[i][j]] to h[i][j] is all >= h[i][j] Let r[i][j] is the index right most element of (i,j) that from h[i][j] to h[i][r[i][j]] is all >= h[i][j] Find max of (j-l[i][j]+r[i][j]-j+1)*h[i][j] for all i,j l and r are calculated in O(n^2) by using the stack */