#K54147. Seating Rows Optimization

    ID: 29689 Type: Default 1000ms 256MiB

Seating Rows Optimization

Seating Rows Optimization

You are organizing seating for an event. Each attendee has a preferred row number indicated by an integer. However, due to space restrictions, each row can only hold at most \(K\) attendees. If the number of attendees preferring a particular row exceeds \(K\), you must use extra rows for that same preference.

Your task is to compute the minimum number of rows required to seat all attendees. For each unique preferred row number, if \(c\) attendees prefer that row, then you need \(\lceil \frac{c}{K} \rceil\) rows. The final answer is the sum of such values over all distinct preferred row numbers.

inputFormat

The input is given via standard input and consists of three lines:

  • The first line contains an integer \(N\) representing the number of attendees.
  • The second line contains \(N\) space-separated integers. Each integer indicates an attendee's preferred row number.
  • The third line contains the integer \(K\), the maximum number of attendees that can be seated in a single row.

outputFormat

Output a single integer denoting the minimum number of rows required to seat all the attendees under the given constraints.

## sample
10
1 2 1 2 3 1 2 3 4 4
3
4