Forming Groups
Time limit5sMemory limit1024 MB
Choose where student 1 stands in the line and a divisor k of n (k above 1) so that the largest-to-smallest ratio of round-robin group sums is minimized.
- Level
Medium5 of 10
- Topics
- Array, Prefix sum, Math
- Solved
- No attempts yet
Problem
There are students, numbered from to , who need to form groups for an upcoming hackathon. You are student , the captain. Student has skill level .
Students to stand in a line from left to right, in order. You can stand between any two students, to the left of student , or to the right of student . The order of the students cannot change.
You can also choose the number of groups , where and is a divisor of . The groups are numbered from to . After you choose your position and , the students are grouped as follows.
The first student from the left is assigned to group , the second to group , and so on up to the -th student, who is assigned to group . The -th student is assigned to group , the -th to group , and this pattern continues until the -th student, who is assigned to group .
Formally, for each () and each (), the -th student from the left is assigned to group . Every student is in exactly one group, and all groups have the same number of students.
The skill level of a group is the sum of the skill levels of its students. Choose your position and to minimize the ratio , where is the largest group skill level and is the smallest.