单调栈真的很好用呢! P2947 [USACO09MAR]向右看齐Look Up 题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those wi…
题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those with higher index numbers. We say that cow…
题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height H_i (1 <= H_i <= 1,000,000). Each cow is looking to her left toward those with higher index numbers. We say that cow…
https://www.luogu.org/problem/P2947 题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Cow i has height Hi (1 <= Hi <= 1,000,000). Each cow is looking to her left toward those with high…
P2947 [USACO09MAR]仰望Look Up 74通过 122提交 题目提供者洛谷OnlineJudge 标签USACO2009云端 难度普及/提高- 时空限制1s / 128MB 提交 讨论 题解 最新讨论更多讨论 中文翻译应当为向右看齐 题目中文版范围.. 题目描述 Farmer John's N (1 <= N <= 100,000) cows, conveniently numbered 1..N, are once again standing in a row. Co…
向右看齐 题目链接 此题可用单调栈O(n)求解 维护一个单调递减栈,元素从左到右入栈 若新加元素大于栈中元素,则栈中元素的仰望对象即为新加元素 每次将小于新加元素的栈中元素弹出,记录下答案 #include<iostream> #include<cstdio> using namespace std; #define N 100010 int n,w[N],stack[N],top,ans[N]; int main() { scanf("%d",&n);…