QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#6604. 狗头人与地下世界

Statistics

Kobolds 是像老鼠一样、喜欢蜡烛的穴居生物,几千年来一直在地表深处挖掘。今天,它们聚集在一起排成一队,准备去探索地下墓穴中的又一条隧道!

但在伟大的行动开始之前,它们必须按照身高非递减的顺序排列。最矮的总是作为挖掘小洞的领队,而追随者则紧随其后。

Kobolds 非常好动;它们喜欢到处乱跑。为了让排列更容易,它们决定先将自己分成若干个连续的组,然后在每个组内重新排序。

问:它们最多可以被分成多少个连续的组,使得在将每个组内的 Kobolds 按非递减顺序重新排列后,整个队列也是非递减的?

例如,给定一个身高为 $[1, 3, 2, 7, 4]$ 的 Kobolds 队列,我们可以将它们分成三个连续的组($[1]$、$[3, 2]$、$[7, 4]$),这样在对每个组重新排序后,整个队列就可以是非递减的。

输入格式

第一行包含一个整数 $n$ ($1 \le n \le 10^6$),表示 Kobolds 的数量。

第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 10^9$),表示队列中 Kobolds 的身高。

输出格式

输出一个整数,表示最大的分组数量。

样例

样例输入 1

5
1 3 2 7 4

样例输出 1

3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.