"Bzoj 1660" [Usaco2006 Nov]bad Hair Day Hair Festival

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.