Kobolds and Catacombs
题号:NC223805
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

Kobolds are rat-like, candle-loving cave folk, digging deep beneath the surface for millennia. Today, they gather together in a queue to explore yet another tunnel in their catacombs!
But just before the glorious movement initiates, they have to arrange themselves in non-descending heights. The shortest is always the leader digging small holes, and the followers swelling it.
The kobolds are hyperactive; they like to move here and there. To make the arrangement easier, they decide to group themselves into consecutive groups first, then reorder in each group.
What's the maximum number of consecutive groups they can be partitioned into, such that after reordering the kobolds in each group in non-descending order, the entire queue is non-descending?
For example, given a queue of kobolds of heights , we can group them into three consecutive groups (), such that after reordering each group, the entire queue can be non-descending.

输入描述:

The first line of the input contains a single integer  , denoting the number of kobolds.
The second line contains integers , representing the heights of the kobolds in the queue.

输出描述:

Print a single integer, denoting the maximum number of groups.
示例1

输入

复制
5
1 3 2 7 4

输出

复制
3