POJ——T 2796 Feel Good】的更多相关文章

http://poj.org/problem?id=2796 Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15375   Accepted: 4252 Case Time Limit: 1000MS   Special Judge Description Bill is developing a new mathematical theory for human emotions. His recent investi…
Feel Good Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 18449   Accepted: 5125 Case Time Limit: 1000MS   Special Judge Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated…
题目链接: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…
http://poj.org/problem?id=2796 题意:给出n个数,问一个区间里面最小的元素*这个区间元素的和的最大值是多少. 思路:只想到了O(n^2)的做法. 参考了http://www.cnblogs.com/ziyi--caolu/archive/2013/06/23/3151556.html的写法,用单调栈可以优化到O(n). 对于每个元素,维护这个元素向前延伸比它大的有多少个,向后延伸比它小的有多少个.即该元素是处于山谷. 那么如何用单调栈维护这个呢? 首先这个栈是单调递…
传送门:http://poj.org/problem?id=2796 题意:给你一串数字,需要你求出(某个子区间乘以这段区间中的最小值)所得到的最大值 例子: 6 3 1 6 4 5 2 当L=3,R=5时这段区间总和为6+4+5=15,最小值为4,所以最后的结果为60. 思路:单调栈的板子题了.没学过单调栈的我只能现学了.单调栈分为单调递增栈,单调递减栈.而这个题呢,要用到单调递增栈.怎么维护单调栈呢?那就是在遇到一个元素大于栈顶元素时,就将该元素加入栈中.(假定即为区间最小值,区间左端点L=…
Feel Good Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 16786   Accepted: 4627 Case Time Limit: 1000MS   Special Judge Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated…
Feel Good Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 20408   Accepted: 5632 Case Time Limit: 1000MS   Special Judge Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated…
Feel Good   Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people's memories about some period of life. A new idea Bill has recently devel…
关于单调栈的性质,和单调队列基本相同,只不过单调栈只使用数组的尾部, 类似于栈. Accepted Code: /************************************************************************* > File Name: 2796.cpp > Author: Stomach_ache > Mail: sudaweitong@gmail.com > Created Time: 2014年07月21日 星期一 22时45…
传送门 Description Bill is developing a new mathematical theory for human emotions. His recent investigations are dedicated to studying how good or bad days influent people's memories about some period of life. A new idea Bill has recently developed ass…