1660: [Usaco2006 nov]bad Hair Day hair Festival time limit: 2 Sec Memory Limit:
Submit: 678 Solved: 326
[Submit] [Status] [Discuss] Description
Input
* Line 1: The number of cattle N.
* Lines 2..n+1: The i+1 is an integer that represents the height of the first cow.
Output
* Line 1: An integer representing c[1] to c[n] and.
Sample Input6
10
3
7
4
12
2
Input explanation:
Six of the cows were lined up in rows of 10, 3, 7, 4, 12, 2, respectively.
Sample Output5
3+0+1+0+1=5HINT
Source
Silver
Monotone queue.
Maintain a single-decrement queue, but be aware that if there is an equality in the evaluation, the latter is counted as equal to him.
#include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include < Cmath> #include <cstring>using namespace std;int n,h[80005];struct qq{int id,v;} Q[80005];int Main () { scanf ("%d", &n), for (int i=n;i>=1;i--) scanf ("%d", &h[i]); Long Long ans=0;int r=1;q [1].v=h[1],q[1].id=1;q[0].id=0;for (int i=2;i<=n;i++) {while (R>=1&&q[r].v
"Bzoj 1660" [Usaco2006 Nov]bad Hair Day Hair Festival