Company: BNY_18nov
Difficulty: medium
Portfolio Backtesting Description A trader backtests a portfolio over n months. pnl[i] is the result of month i : a profit when it is non-negative, a loss when it is negative. Walking through the months in order, the trader: always banks a non-negative pnl[i] ; for a negative pnl[i] , either takes the loss, adding that negative value to the running total, or skips the month entirely. The running total must be non-negative after every month -- the trader may never be down. At least k of the months must be taken as losses. Report the largest final total that can be reached while taking at least k losses, or -1 when that is impossible. Complete the function getMaxProfit in the editor below. Function Signature long long getMaxProfit(int n, vector<int> pnl, int k); Input The input is read from standard input as whitespace-separated integers, in this order: n , the number of months. n integers, one per line, the array pnl . k , the minimum number of losses to take. Output Print a singl