Question: Give the idea of solve this problem ( Method 1 ) Take the scores of n students as input, sort them in descending order, and

Give the idea of solve this problem
(Method 1)
Take the scores of n students as input, sort them in descending order,
and then divide them into k groups.
Assume that the lower group numbers correspond to higher scores.
Starting from i =1 up to k-1, calculate the differences between the
minimum score of the i^th group and the maximum score of the (i+1)^th
group, and maximize the sum of these differences.
However, each group must have at least one student.
Print to standard output and write to files simultaneously.
Print the (maximum) sum of differences in Method 1 on the first line
of standard output.
Write the groups from Method 1 to a file (filename: Partition1.txt).
The first line of the file corresponds to Group 1, and the k
th line
corresponds to Group k. Each line lists "student number (student
score)" in ascending order of student numbers.
Input/Output Example
ex1
Input (standard/console input)
153
505010205010505020205050505010
Output (standard/console output)
40
0
Output (filename: Partition1.txt)
1(50)2(50)5(50)7(50)8(50)11(50)12(50)13(50)14(50)
4(20)9(20)10(20)
3(10)6(10)15(10)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!