QOJ.ac

QOJ

时间限制: 2 s 内存限制: 256 MB 总分: 100

#1494. 贪婪的礼物接收者

统计

Farmer John 的宿敌 Farmer Nhoj 有 $N$ 头奶牛($1 \leq N \leq 10^5$),编号分别为 $1 \dots N$。它们意外地出现在了 Farmer John 的农场,因此一向彬彬有礼的 Farmer John 试图给它们送礼物。

为此,Farmer John 拿出了他无限供应的礼物,Nhoj 的奶牛们在他面前排成一队,奶牛 $1$ 在队首,奶牛 $N$ 在队尾。Farmer John 原本以为在每个时间步,队首的奶牛会从他那里拿走一份礼物并走到队尾。然而,他刚刚意识到 Nhoj 的奶牛们并没有那么礼貌!每头奶牛在收到礼物后,可能不会走到队尾,而是会插队到队尾若干头奶牛的前面。具体来说,奶牛 $i$ 总是会插到 $c_i$ 头奶牛的前面($0 \leq c_i \leq N-1$)。

Farmer John 知道有些奶牛可能会收到多份礼物;由于他有无限的供应,这并不让他担心。但他担心如果有些奶牛收不到任何礼物,它们会变得不高兴。

请帮助 Farmer John 计算出无论分发多少份礼物,永远收不到礼物的奶牛数量。

输入格式

第一行包含一个整数 $N$。

第二行包含 $N$ 个空格分隔的整数 $c_1, c_2, \dots, c_N$。

输出格式

请输出无法收到任何礼物的奶牛数量。

样例

输入格式 1

3
1 2 0

输出格式 1

1

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.