P2866 [USACO06NOV]糟糕的一天Bad Hair Day 75通过 153提交 题目提供者洛谷OnlineJudge 标签USACO2006云端 难度普及/提高- 时空限制1s / 128MB 提交 讨论 题解 最新讨论更多讨论 题目标题 题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her…
题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of other cows' heads. Each cow i has a specified…
题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of other cows' heads. Each cow i has a specified…
https://www.luogu.org/problem/show?pid=2866 题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the top of o…
链接:https://ac.nowcoder.com/acm/contest/984/A 来源:牛客网 题目描述 Some of Farmer John's N cows (1 ≤ N ≤ 80,000) are having a bad hair day! Since each cow is self-conscious about her messy hairstyle, FJ wants to count the number of other cows that can see the…
看到这道题很容易想到单调栈,但我一开始想的是从后往前扫,但发现会有问题(因为这样会对后面牛的答案造成影响),所以这时我们要及时换一个思路,从前往后扫. 维护一个单调递减的栈,插入h[i]时,小等于它的数都要出栈,累加栈中元素数量,表示的意义就是:当前栈中的牛都是可以看到i这头牛的,即他们不会被i这头牛挡住. 1 #include<bits/stdc++.h> 2 using namespace std; 3 long long ans,h[80010]; 4 int s[80010],top,…