[BOJ 7261] Swimming competition

View as PDF

Submit solution

Points: 3
Time limit: 1.0s
Memory limit: 1G

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Every pupil can participate in an open swimming competition in Bitlandia. Since registration in advance is not mandatory, organisers never know how many pupils will participate.</p>

This year, the number of pupils attending is smaller than the number of swimlanes in Bitlandia, which is 500 000. The organisers decided to split the participants into smaller groups with at least A and at most B participants each.

Also, the organisers want to make the competition as fun as possible by making the speed of the swimmers in each group as similar as possible.

Write a program that divides the swimmers into groups so that the maximum, over all groups, of the absolute time difference between the slowest and the fastest swimmers is the smallest possible.

입력 형식

There are three numbers given in the first line: the number of participants who came to competition (N) and the minimum (A) and maximum (B) possible number of swimmers in each group.</p>

The following N lines contain the times ti that the swimmers take to complete the distance.

The input always leads to an existing solution.

출력 형식

The output should be a single number – the smallest possible maximum, over all groups, of the difference between the times of the slowest and the fastest swimmers.

예제 입력 1

5 2 4
1
3
3
1
4

예제 출력 1

1

예제 입력 2

8 3 5
1
5
8
8
1
1
8
10

예제 출력 2

4

Comments

There are no comments at the moment.