题目链接:http://poj.org/problem?id=2796 单调栈可以O(n)得到以每个位置为最小值,向左右最多扩展到哪里. #include<cstdio> #include<algorithm> #include<stack> using namespace std; ; int a[maxn]; int l[maxn]; int r[maxn]; long long pre[maxn]; stack< pair<int,int> &g…
1619 - Feel Good Time limit: 3.000 seconds Bill is developing a new mathematical theory for human emotions. His recent investigations are dedi- cated to studying how good or bad days in uent people's memories about some period of life. A new idea B…
给出一系列的1*h的矩形,求矩形的最大面积. 如图: 题解链接:点我 #include <iostream> #include <cstdio> using namespace std; ; struct Elem { int height; int count; }; Elem stack[N]; int top; int main() { int height, n; long long ans, tot, tmp; while (scanf("%d", &…
和poj2082差不多,加了一个宽度的条件 #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<iostream> using namespace std; ; pair<int,int> ele[MAXN]; int main(){ int height, n; int w; int i,j,k,h; int ans, tot…