#C3837. Sortland: Wealth Ranking of Towns
Sortland: Wealth Ranking of Towns
Sortland: Wealth Ranking of Towns
Given n towns and their respective wealth values, your task is to determine the 1-based indices of the towns with the least wealth, median wealth, and greatest wealth.
You are provided with a list of wealth values and must output three integers: the index of the town with minimum wealth, the index of the town with median wealth, and the index of the town with maximum wealth. The median is defined as the town in the middle position when the towns are sorted in increasing order by wealth. All indices are 1-based.
For example, if n = 5 and the wealth values are [4, 1, 7, 3, 9], then the sorted order of towns maps to original indices as follows: town with wealth 1 has index 2, town with wealth 3 has index 4, town with wealth 4 has index 1, town with wealth 7 has index 3, and town with wealth 9 has index 5. Hence, the answer is 2 1 5 (least, median, greatest).
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains a single odd integer n representing the number of towns.
- The second line contains n space-separated integers representing the wealth values of the towns.
outputFormat
Output three integer indices (1-based) corresponding to the towns with the least wealth, median wealth, and greatest wealth, respectively. The output should be printed as a single line with the numbers separated by a space to standard output (stdout).
## sample5
4 1 7 3 9
2 1 5