Problem P
Stalínröðun
Languages
en
is
One of the many times Unnar was scrolling and looking through new posts on the social media site ReadIt he saw a post on /l/codingjests about Stalinsort. In it a linear sorting algorithm was described, it worked by eliminating all elements that aren’t in increasing order.
Then Unnar started to think ,,What about instead of deleting all elements that aren’t in increasing order we delete the ones that are in increasing order?”. A very normal question to ask then is how many iterations it would take to end up with an empty list.
An element
Input
The first line of the input contains one integer
Output
Print the number of iterations to end up with an empty list.
Example
[ 1 7 5 8 6 3 2 4 ]
After the first iteration:
[ 5 6 3 2 4 ]
After the second iteration:
[ 3 2 4 ]
After the third iteration:
[ 2 ]
After the fourth iteration:
[ ]
Thus the answer is four.
Scoring
Group |
Points |
Constraints |
1 |
20 |
|
2 |
30 |
|
3 |
50 |
No further constraints |
Sample Input 1 | Sample Output 1 |
---|---|
3 2 1 3 |
2 |
Sample Input 2 | Sample Output 2 |
---|---|
8 1 7 5 8 6 3 2 4 |
4 |