#C13697. Maximum Stock Profit
Maximum Stock Profit
Maximum Stock Profit
You are given a sequence of stock prices. Your task is to compute the maximum profit that can be achieved by buying and selling the stock exactly once. If no profit can be made, output 0. If the input contains any non-numerical values, you must output an error message exactly as shown below:
\(\text{Error: The list contains non-numerical values.}\)
inputFormat
The input is provided on a single line via standard input. It contains space‐separated tokens where each token represents a stock price, which may be given as an integer or a floating-point number (in standard or scientific notation).
outputFormat
Print a single line to standard output. This line should display the maximum possible profit computed from the given stock prices. If the input contains any non-numerical values, output Error: The list contains non-numerical values.
7 1 5 3 6 4
5