1. There is a set of 9 students and 3 schools Every school can be alloted atmax 3 students .Every school and student has its coordinates .Now we have to allot student in such a way that the sum of distance from all the student to the school should be minimum.
2. In a library there are N books with the number of pages in ith book given by b_i.These books are to be distributed among K students such that the difference between the largest sum of pages in the books assigned to any student and the smallest sum of number of pages in the books assigned to any student is minimum for the given input. Also the books are arranged in a certain order and this order must never be changed.
For example:
suppose B[] contains the number of pages in each book.
Then for N=6 K=3 B={3,7,8,2,6,4}, the output will be 0 as we can give book 1 and 2 to student 1 and book 3 and 4 to student 2 and the remaining to student 3. That makes 10 pages for student 1 10 for 2 and 10 for 3 and thus the difference is 0
similarly when B={3,6,8,2,6,4} then the minimum difference will be 1 .
2. In a library there are N books with the number of pages in ith book given by b_i.These books are to be distributed among K students such that the difference between the largest sum of pages in the books assigned to any student and the smallest sum of number of pages in the books assigned to any student is minimum for the given input. Also the books are arranged in a certain order and this order must never be changed.
For example:
suppose B[] contains the number of pages in each book.
Then for N=6 K=3 B={3,7,8,2,6,4}, the output will be 0 as we can give book 1 and 2 to student 1 and book 3 and 4 to student 2 and the remaining to student 3. That makes 10 pages for student 1 10 for 2 and 10 for 3 and thus the difference is 0
similarly when B={3,6,8,2,6,4} then the minimum difference will be 1 .
No comments:
Post a Comment