M. 收集数字

    Type: Default 1000ms 256MiB

收集数字

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

翻译自 CSES-2216 题。

题目描述

给你一个数组,其中包含 1n1\dots n 之间的每个数字。你的任务是按递增顺序收集从 11nn 的数字。

在每一轮中,你从左到右遍历数组,收集尽可能多的数字。

求要收集多少轮?

输入格式

第一行输入一个整数 nn,代表数组大小。

第二行输入 nn 个整数 x1,x2,,xnx_1,x_2,\dots,x_n,分别代表数组中的数字。

输出格式

输出一个整数,表示轮数。

样例

5
4 2 1 5 3
3

说明/提示

1n21051 \leq n \leq 2\cdot 10^5

CSES练习二 排序贪心STL

Not Claimed
Status
Done
Problem
35
Open Since
2025-5-1 0:00
Deadline
2025-5-31 23:59
Extension
24 hour(s)