#C7322. Departments with Extreme Sentiments

    ID: 51181 Type: Default 1000ms 256MiB

Departments with Extreme Sentiments

Departments with Extreme Sentiments

In this problem, you are given data for multiple departments, where each department has a list of sentiment scores. Your task is to determine the department with the highest average sentiment and the one with the lowest average sentiment. The average sentiment score for a department is calculated using the formula: (\text{average} = \frac{\sum_{i=1}^{k} s_i}{k}), where (s_i) represents each sentiment score and (k) is the number of scores. In case of ties in the average score, tie-breaking is performed based on the ASCII value of the first character of the department name. Specifically, for the highest average, the department with the smaller ASCII value (i.e. larger negative value when negated) of its first character is chosen, and for the lowest average, the department with the smallest ASCII value is selected. All input will be read from stdin and output should be written to stdout.

inputFormat

The first line contains a single integer (n) representing the number of departments. This is followed by (n) lines, each containing a department name and a sequence of integers separated by spaces. The department name is a string and the subsequent numbers represent the sentiment scores for that department. Input is given via standard input (stdin).

outputFormat

Output the department with the highest average sentiment and the department with the lowest average sentiment, separated by a space, on a single line. The output should be sent to standard output (stdout).## sample

3
sales 5 4 3 5 4
hr 2 3 4 3
engineering 5 5 4 5 5 4 5 3
engineering hr