Codeforces548D:Mike and Feet(单调栈)】的更多相关文章

Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears…
B. Mike and Feet Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B Description Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standi…
题目链接 用单调栈计算出一个数字, 左边第一个比他小的数字的位置, 右边比第一个他小的数字的位置, 然后len = r[i] - l[i] +1. ans[len] = max(ans[len], a[i]) #include<bits/stdc++.h> using namespace std; ; int l[maxn], r[maxn], ans[maxn], a[maxn], q[maxn]; int main() { int n; cin>>n; ; i<=n; i…
D. Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are…
这道题用单调递增的单调栈维护每个数能够覆盖的最大区间即可. 对于   1 2 3 4 5 4 3 2 1 6 这组样例, 1能够覆盖的最大区间是10,2能够覆盖的最大区间是7,以此类推,我们可以使用单调栈来实现这种操作. 具体看代码: *Code: #include<bits/stdc++.h> using namespace std; ],r[],ans[],a[]; ],top=; void solve(){ a[n+]=-; ;i<=n+;i++){ ||a[stk[top-]]&…
Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are st…
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears…
题意 n个值代表n个熊的高度 对于size为x的group strength值为这个group(连续的几个熊)中熊的最小的height值 对于x(1<=x<=n) 求出最大的strength值 http://codeforces.com/contest/548/problem/D 思路 我们把每个数作为最小值能最远向左和右用单调栈处理出来,那么可以发现对于x长度的所有group,某个数延伸的区间长度如果大于等于x,则这个数对答案有贡献. 对于样例,我们处理出来后可以观察发现确有此规律: 然后就…
Mike and Feet Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 548D Appoint description:  Description Mike is the president of country What-The-Fatherland. There are n bears living in thi…
Mike and Feet time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are st…