Daeners And The Queen's Guard Analysis

Satisfactory Essays
Daenerys and the Queen’s Guard Daenerys has a large army of soldiers, she must now choose at most 3 soldiers from her army to form the Queen’s Guard. The Queen’s Guard should have the best soldiers from the army. Forming The Queen’s Guard is a tedious process, inorder to find the best soldiers we need to find i, j, and k such that: p * ai + q * aj + r * ak (1 ≤ i ≤ j ≤ k ≤ N) has the maximum value. Givent the size of the army N, value of p, q, and r and the skill level of each quard ai, can you help find the maximum value? (Maximum value maybe negative) Input The first line contains 4 integers N, p, q, r The next line contains N integers a1, a2, a3, . . . , an Output The maximum value p * ai + q * aj + r * ak such that
    Get Access