#P4447. [AHOI2018初中组] 分组
[AHOI2018初中组] 分组
Description
There are members in Coco's school's informatics team, and each person has a strength value . The annual programming contest is coming, and the school has obtained several participation slots. The coach decides to divide the team members into several groups to participate in the contest.
However, no one wants to team up with someone whose strength differs too much from their own, so each group must consist of members whose strength values form a consecutive sequence. Also, no two players in the same group may have the same strength value. For example: is a valid grouping because the strengths are consecutive; is not valid because the strengths are not consecutive; is also not valid because two players have the same strength value .
If a group is too small, it will not have enough time to score well. Therefore, Coco wants you to give a valid grouping that assigns everyone to exactly one group and maximizes the size of the smallest group. Output the maximum possible size of the smallest group.
Note: Strength values can be negative, and there is no limit on the number of groups.
Input Format
Two lines:
The first line contains a positive integer , the number of team members.
The second line contains integers. The -th integer denotes the strength of the -th player.
Output Format
Output one line containing a single positive integer: the maximum possible size of the smallest group.
7
4 5 2 3 -4 -3 -5
3
Hint
Sample Explanation
Divide into groups: one group has strengths , and the other has . The smallest group size is , and there is no better grouping than .
Constraints
For of the testdata: , .
This problem has test points, numbered , each with additional guarantees as follows: | Test point ID | Constraints | | :-----------: | :-----------: | | | , | | | , and are all distinct | | | , are all distinct | | | , | | | , |
Translated by ChatGPT 5
京公网安备 11011102002149号