Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( Method 1 ) Let's first implement Professor Kim's method properly: Take the scores of n students as input, sort them in descending order, and

(Method 1) Let's first implement Professor Kim's method properly:
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 ith 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.
(Method 2) Now, let's implement a better method:
Similarly, take the scores of n students as input, sort them, and then divide them into k groups.
Again, assume that lower group numbers correspond to higher scores.
It would be ideal if the scores of students within each group were similar.
Therefore, calculate the variance of student scores in each group, and aim to minimize the sum of these variances across all groups.
However, each group must have at least one student, and the variance of a group with only one student is considered to be 0.
Take input from standard input.
The first line contains n and k.
The next line contains the scores of n students in ascending order of enrollment numbers.
Here, n is a number greater than or equal to k.
Each score can range from 0 to 1,000, and ties are possible.
Surprisingly, n can be as large as 104.
k is a positive integer less than or equal to 12.(Note: depending on the school, each grade (A, B, C, D) may be divided into 2 or 3 categories)
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 kth line corresponds to Group k. Each line lists "student number (student score)" in ascending order of student numbers.
Print the (minimum) sum of variances in Method 2 on the second line of standard output (rounded to three decimal places).
Write the groups from Method 2 to a file (filename: Partition2.txt). The first line of the file corresponds to Group 1, and the kth line corresponds to Group k. Each line lists "student number (student score)" in ascending order of student numbers.
Please write it in c++ code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is quality of work life ?

Answered: 1 week ago

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

Explain the key components of an assessment center (AC).

Answered: 1 week ago