#C1745. Product Sales Analysis
Product Sales Analysis
Product Sales Analysis
You are given a list of products together with their sales numbers. Your task is to identify the product with the highest sales and the product with the lowest sales. Formally, if you have products \(P = \{(c_i, s_i)\}\), where \(c_i\) is the product code and \(s_i\) is the number of units sold, then you need to find:
- \(\max_{i} s_i\) and its corresponding product code.
- \(\min_{i} s_i\) and its corresponding product code.
If there is only one product, then that product's code is considered as both the maximum and the minimum. The input is provided via standard input, and the output should be printed to standard output, each on a separate line.
inputFormat
The first line contains an integer \(n\) denoting the number of products. The following \(n\) lines each contain a product code (a string without spaces) and an integer representing the units sold, separated by a space.
outputFormat
Output two lines: the first line should contain the product code with the highest sales, and the second line should contain the product code with the lowest sales.
## sample4
A123 500
B456 200
C789 150
D012 650
D012
C789
</p>