#K92467. Maximize Profit
Maximize Profit
Maximize Profit
You are given the prices of a stock over a series of days. Your task is to determine the best day to buy and the best day to sell the stock in order to maximize profit. The days are indexed starting from 0. The profit is defined as the difference between the selling price and the buying price. Only a single transaction (one buy and one sell) is allowed. If no profit can be made, you should output 0 0
.
inputFormat
The input is read from standard input (stdin).
The first line contains a single integer n
which represents the number of days. The second line contains n
space-separated integers representing the stock prices on each day. If n
is 0, then there are no stock prices.
outputFormat
The output should be printed to standard output (stdout) as two space-separated integers representing the day to buy and the day to sell, respectively. If no profit is possible, output 0 0
.## sample
6
7 1 5 3 6 4
1 4