LCC '25 Contest 1 S3 - Sadness
View as PDFBob the ghost observes a line of  distinct houses, each containing a lit jack o' lantern labelled by a (not necessarily distinct) integer 
. Bob floats from 
 to 
 across the line of houses from one end to the other, and since Bob despises happiness, he extinguishes each jack o' lantern in order from least to greatest (he cannot skip any numbers). Assume Bob teleports to the start (leftmost point) after every pass. How many passes does he need in total to extinguish every jack o' lantern?
Input Specification
The first line of input contains one integer , representing the number of houses on the street.
The second line of input contains  space-separated integers 
, representing the integer associated with each jack o' lantern.
Output Specification
Output one integer, indicating the least number of passes Bob needs to extinguish all jack o' lanterns.
Constraints
For all subtasks, 
Subtask 1 [5%]
Subtask 2 [25%]
Subtask 3 [70%]
Sample Input
7
1 2 5 5 4 1 3Sample Output
4Sample Explanation
During Bob's first pass, he extinguishes the  and 
 jack o' lantern. During Bob's second pass, he extinguishes the 
 and 
 jack o' lantern. During Bob's third pass, he extinguishes the 
 jack o' lantern. Finally, during Bob's fourth pass, he extinguishes the remaining 
 and 
 jack o' lantern.
Comments