#K51342. Best Candidate Selection
Best Candidate Selection
Best Candidate Selection
You are given a list of candidates. Each candidate is described by their name, age, and score. Your task is to select the candidate with the highest score. In case of a tie (i.e. multiple candidates having the same highest score), choose the candidate with the smallest age (i.e. the youngest candidate among them).
If no candidate is provided, output None
.
Mathematically, if we denote the score of the i-th candidate as \(score_i\) and the age as \(age_i\), you need to select a candidate \(j\) such that:
[ score_j = \max_{1 \leq i \leq n} { score_i } \quad \text{and} \quad age_j = \min{ age_i \mid score_i = score_j } ]
inputFormat
The input is provided via standard input (stdin) in the following format:
The first line contains a single integer \(n\) representing the number of candidates. Each of the following \(n\) lines contains three space-separated values: - A string representing the candidate's name. - An integer representing the candidate's age. - An integer representing the candidate's score.
If \(n = 0\), there will be no candidate information.
outputFormat
Output to standard output (stdout) a single line with the name of the best candidate as per the rules above. If there are no candidates, output None
.
3
Alice 30 85
Bob 25 90
Charlie 35 90
Bob