Recently, a Data Analyst Hiring contest was conducted at HackerEarth and our guy Fredo is assigned the task to provide a list of all shortlisted students. He is given three tables:
1. Candidates : It consists of Name of candidate, his UserId and his Skill (in particular Skill rating). All candidates have different UserId and Skills.
2. Problems: It consists of ProblemName and it's Score.
3. Submissions: It consists of UserId and ProblemName. Any row of this table indicates that the particular candidate has solved that problem and will be awarded the score attached to that problem.
The candidates will get shortlisted on the basis of their total scores,i.e., candidate having more total score will be preferred over one having less total score. If two candidates have same total scores, the one having more skill rating will be preferred.
The cutoff score is 50, meaning that only those students having total score atleast 50 can be shortlisted. If there are more than 8 candidates clearing the cut off score , only top 8 would be selected.
The output table should be ordered by total score. In case total score of two candidates is the same, it should be ordered by their skill rating.
Total score of a candidate means the sum of the scores of all the problems solved by him.
It is guaranteed that atleast one candidate will be shorlisted.
Table : Candidates
Sample Candidates Table:
Sample Problems Table:
Sample Submissions Table: