#C2125. Snowball Throw
Snowball Throw
Snowball Throw
In a local snowball fight, a group of players participate until only one remains. In each throw, one player is eliminated. The rules of elimination allow two strategies:
Minimum Throws: The strongest player eliminates all others one by one. This requires exactly \(n-1\) throws.
Maximum Throws: The players are eliminated gradually in a way that maximizes the number of throws. In this scenario, the total number of throws is \(\frac{n(n-1)}{2}\), which is the sum of the first \(n-1\) natural numbers.
You are given a list of integers representing the strengths of each player. Regardless of the order of strengths, the outcome (number of minimum and maximum throws) depends only on the total number of players \(n\). Write a program that reads the number of players and their strengths from standard input and prints the minimum and maximum number of throws required to leave one player standing.
Note: The strengths are provided as input, but they do not affect the calculations.
inputFormat
The input is given from standard input in the following format:
n s1 s2 ... sn
Here, n
is an integer indicating the number of players, and s1, s2, ..., sn
are the strengths of the players (integers).
outputFormat
Output to standard output two integers separated by a space: the minimum and maximum number of throws required to leave one player standing.
These values are given by:
- Minimum throws = \(n - 1\)
- Maximum throws = \(\frac{n(n - 1)}{2}\)
3
3 1 2
2 3