#C2415. Maximum Product of Three Servers
Maximum Product of Three Servers
Maximum Product of Three Servers
You are given a list of processing powers of n servers. Your task is to select three servers with distinct indexes (\(i, j, k\) where \(i < j < k\)) such that the product of their processing powers is maximized.
Formally, given an integer \(n\) and a list of integers \(p_1, p_2, \dots, p_n\), find the maximum value of \(p_i \times p_j \times p_k\) for any indices \(i, j, k\) satisfying \(1 \le i < j < k \le n\).
It can be shown that the answer is either the product of the three largest numbers or the product of the two smallest numbers (which may be negative) and the largest number.
inputFormat
The input is given via standard input (stdin) and has the following format:
- The first line contains an integer \(n\) (\(n \geq 3\)), the number of servers.
- The second line contains \(n\) space-separated integers representing the processing powers of the servers.
outputFormat
Output via standard output (stdout) a single integer representing the maximum product of the processing powers of three servers chosen with strictly increasing indices.
## sample5
1 2 3 4 5
60