1660: [Usaco2006 nov]bad Hair Day Hair FestivalTime Limit:2 Sec Memory limit:64 MBsubmit:665 solved:318[Submit] [Status]DescriptionInput* 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 Input
1660: [Usaco2006 nov]bad Hair Day hair Festival time
limit: 2 Sec
Memory Limit:
Submit: 678
Solved: 326
[Submit] [Status] [Discuss]
DescriptionInput* 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 re
bzoj1660[usaco2006 Nov]bad Hair Day Hair FestivalTest instructionsGive a sequence a, so that ci=ai+1 to the first greater than AI position J and I distance. Seek Sigma (I,1,n) ci.ExercisesMaintained with a descending monotonic stack. Note that the final answer is to open a long long.Code:1#include 2#include 3#include 4
Description
Input
* Line 1: Number of cattle n.
* Lines 2. n + 1: The I + 1 is an integer that indicates the height of the I head ox. Output
* Line 1: an integer that represents the sum of C [1] to C [N.
Question:
The bzoj server seems to be faulty, and the picture is not displayed properly. Just look at the above picture.
Set Niu I to see the farthest position: see [I].
Scan from the front to the back
1660: [usaco Nov] bad hair day error message time limit: 2 sec memory limit: 64 MB
Submit: 606 solved: 289
[Submit] [Status]
Description
Input
* Line 1: Number of cattle n.
* Lines 2. n + 1: The I + 1 is an integer that indicates the height of the I head ox.Output
* Line 1: an integer that represents the sum of C [1] to C [N.Sample input6
10
3
7
4
12
2
Input
or monotonous stack, maintenance is reduced, in the calculation, note to save before a number larger than the current before a few smaller than it.1 varN,i,j,num,now,tem:longint;2 Ans:int64;3stack:array[0..1000001] of Longint;4h,l:array[0..1000001] of Longint;5 begin6 READLN (n);7 fori:=1to n Do8 readln (H[i]);9now:=0;Tenans:=0; One //Fillchar (l,sizeof (L), 1); A fori:=1to n Do -l[i]:=1; - forI:=n Downto1 Do the begin - while(H[i]>
Poj 3250 Bad Hair Day (monotonous stack)Bad Hair Day
Time Limit:2000 MS
Memory Limit:65536 K
Total Submissions:14883
Accepted:4940
Description
Some of Farmer John'sNCows (1 ≤N≤ 80,000) are having a bad
POJ 3250 Bad Hair Day simulated monotonous Stack
Bad Hair Day
Time Limit:2000 MS
Memory Limit:65536 K
Total Submissions:14989
Accepted:4977
Description
Some of Farmer John'sNCows (1 ≤N≤ 80,000) are having a bad
Bad Hair Day
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 17727
Accepted: 5981
Description Some of Farmer John ' SNBSP; N cows (1≤NBSP; N ≤ 80,000) is has a bad hair day! Since Each cow was se
DescriptionSome of Farmer John ' s N cows (1≤n≤80,000) is having a bad hair day! Since Each cow was self-conscious about she messy hairstyle, FJ wants to count the number of other cows so can see the to P of other cows ' heads.Each cow I have a specified height hi (1≤hi≤1,000,000,000) and is standing in a line of cows
http://poj.org/problem?id=3250
Bad Hair Day
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 15956
Accepted: 5391
DescriptionSome of Farmer John ' s n cows (1≤ n ≤80,000) is has a bad
Bad Hair Day
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 14989
Accepted: 4977
DescriptionSome of Farmer John ' s n cows (1≤ n ≤80,000) is has a bad hair day! Since Each cow was self-conscious abou
Topic Link: Poj 3250 bad Hair Day
Bad Hair DayTime limit:2000ms Memory limit:65536kTotal submissions:16700 accepted:5621Description
Some of farmer John ' s N cows (1≤n≤80,000) are have a bad hair day! Since Each cow are self-consc
http://poj.org/problem?id=3250Bad Hair Day
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 15985
Accepted: 5404
DescriptionSome of Farmer John ' s n cows (1≤ n ≤80,000) is has a bad hair day! Since Each cow was self-conscious about she messy hai
Bad Hair DayTest instructions: to N (n Idea: Each head to the stack of cows, the top of the stack than its dwarf cattle out of the stack, because these cows have no chance to see the cattle back, so out of the stack, then add the number of elements in the stack can;#include #include#include#includestring.h>#include#include#include#include#include#include#includeSet>#include#includeusing namespacestd;#define
Description
Some Of Farmer John'sNCows (1 ≤N≤ 80,000) are having a bad hair day! Since each cow is self-conscious about hermessy hairstyle, FJ wants to count the number of other cows that can see thetop of other cows 'heads.
Each cowIHas a specified heightHi(1 ≤Hi≤ 1,000,000,000) and is standing in a line of cowsall fa
Address: poj 3250
Monotonous stack for beginners. Multiple schools and online competitions have already met each other twice.
The monotonous stack principle is simple and cannot be simple .. It is to make the elements in the stack monotonically from the top of the stack to the bottom of the stack.
For example, incremental and monotonous stacks.
If the number at the top of the stack
Question link: http://poj.org/problem? Id = 3250
Train of Thought Analysis:
The question requires the sum of the number of cows that each ox sees, that is, the sum of the number of times each ox sees;
How can we determine the number of times each ox is seen?
For a particular ox, the ox who sees it must be on its left, and its height should be higher than that of the ox, therefore, you only need to calculate
Test instructionsA row of cows stood in a row, giving the height of a cow, and each cow could only look right, with a c[i for each cow]C[i] For I can see how many cows, short cows see high cattle, ask all c[i] and is how much.Ideas:We convert, in fact, to find out how many times each cow can be seen, and apparently it can be seen by cows that are monotonically increasing to the left.Then we maintain a monotonous stack, each time will be less than equa
here Everybody estimate already confused, even I am sure some stationmaster must be in scold what I want to express what exactly? redirect is not the two kinds: 1, 301 Permanent Redirect, the original page accumulated weight will be transferred to the new page, 2, 302 temporary movement; It can only be used for domain name jump instead of passing and transfer the weight of the page before;
Well, these basic knowledge to review almost, I guess listen
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.