Best Class Total When Close Friends Get Different Papers

Company: Meltwater_30oct

Difficulty: hard

Problem Statement

Best Class Total When Close Friends Get Different Papers A lecturer sends a class of N students home with an open-book paper. She has prepared K different papers, numbered 1 to K ; paper j is worth M[j] marks, and every student who attempts a paper is certain to score its full value. Friendships in the class form a tree: there are exactly N - 1 friendships, each joining two students, and every pair of students is linked through a chain of friendships. Nobody has more than F friends. To stop answers from being shared, the lecturer hands out the papers under one rule: two students who are friends, or who have a friend in common, must not receive the same paper. In other words, whenever student A is friends with both B and C , the three of them sit three different papers. Students who are further apart may receive the same paper. Every student sits exactly one paper. Choose a paper for every student so that the rule holds and the total of all marks is as large as possible, and report that