TopCoder problem "TeamSelection" used in TCHS SRM 62 (Division I Level One)

Problem Statement

    You are a programming team coach, and your task is to put together the best possible team of three students. There are several students willing to join the team, and their ratings are given in the int[] ratings, where the i-th element is the rating of the i-th student. Unfortunately, some students cannot work together. You are given a String[] compatibility, where the j-th character of the i-th element is 'Y' if the i-th student and j-th student can work together, and 'N' otherwise. You must pick a team of three students such that everybody on the team can work with everybody else on the team, and the sum of their ratings is as high as possible. Return the sum of the team members' ratings, or -1 if it is impossible to pick such a team.


Parameters:int[], String[]
Method signature:int selectBestTeam(int[] rating, String[] compatibility)
(be sure your method is public)


-rating will contain between 3 and 50 elements, inclusive.
-Each element of rating will be between 1 and 1000, inclusive.
-compatibility will contain the same number of elements as rating.
-Each element of compatibility will contain exactly n characters, where n is the number of elements in compatibility.
-compatibility will contain only the characters 'Y' and 'N'.
-The i-th character of the j-th element of compatibility will be equal to the j-th character of the i-th element of compatibility.
-The i-th character of the i-th element of compatibility will be 'Y'.


Returns: 9
Every student can work together with every other student.
Returns: -1
No team can be composed because there is no pair of students who can work together.
Returns: -1
{750, 911, 451, 578, 337, 894, 549, 620, 509, 672, 465, 562, 138, 939, 113}
Returns: 2744

Problem url:

Problem stats url:




PabloGilberto , Olexiy , ivan_metelsky

Problem categories:

Brute Force