#P2062. 分队问题

分队问题

Description

Given nn players, partition them into several teams. The ii-th player requires that the size of their team be at least aia_i.

Subject to satisfying all players' requirements, maximize the total number of teams.

Note: Each player belongs to exactly one team.

Input Format

The first line contains an integer nn, the number of people.

The next nn lines each contain an integer aia_i.

Output Format

Output the maximum possible number of teams. It is guaranteed that a solution exists.

5
2
1
2
2
3 

2

Hint

  • For 20% of the testdata, n10n \leq 10.
  • For 40% of the testdata, n1000n \leq 1000.
  • For 60% of the testdata, n10000n \leq 10000.
  • For 100% of the testdata, 1n1061 \leq n \leq 10^6.

Translated by ChatGPT 5