SAC '21 Code Challenge P3 - DeMello's Replacement

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 256M

Authors:
Problem type

Mr. DeMello wants to find a replacement for himself before retiring. He has determined how to score them and uses the equation S = 4 \times \sqrt{M} + 3 \times {CS}^{P} - 4 \times E, where M is the student's math grade, CS is the student's computer science grade, E is the student's English grade, and P is an integer of Mr. DeMello's choice. Given N students, Mr. DeMello wants you to determine the student with the highest score and the student with the lowest score rounded down to the closest integer.

Input Specification

The first line will consist of a positive integer N (2 \leq N \leq 100\,000) and P (0 \leq P \leq 5).

The next N lines will consist of the name of the i^\text{th} student (with no spaces between characters) and their math (0 \leq M \leq 100), computer science (0 \leq CS \leq 100), and English mark (0 \leq E \leq 100) separated by a space.

Note: The maximum and minimum scores will be distinct from every other score (even after rounding down), and P and CS will not both be 0.

Output Specification

On the first line of output, output the name of the student with the highest score followed by their score S, separated by a space and rounded down to the closest integer.

On the second line of output, output the name of the student with the lowest score followed by their score S, separated by a space and rounded down to the closest integer.

Sample Input

3 2
Zain 98 99 96
Max 92 100 2
Ethan 34 57 58

Sample Output

Max 30030
Ethan 9538

Comments

There are no comments at the moment.