Given an array of integers A and 2 operations with costs X and Y,
1. Choose subarray A[L...R] and subtract 1 from all elements in the subarray.
2. Choose index i such that A[i] > 0 and set A[i] = 0
Goal is to return minimum cost of converting all elements of array to 0.
Example:
INPUT
A = [1,1,1]
X = 1
Y = 2OUTPUT
1Explanation: We can do operation 1 on A[0..2] with cost of X = 1.
Golden Divisor of a integer n is it's largest divisor less than itself.
Eg: Golden divisor of 12 is 6 since divisors of 12 are [1,2,3,4,6,12] amd maximum divisor less than 12 is 6.
Khaled and Ali decided to play a game with T nums. They play alternately and Khaled always starts first.
In each turn, a player can pick one number X and replace it with any positive number Y such that Y < X and Y has same golden divisor as X.
A player who cannot make a move loses. Each player will play optimally and you should determine the winner,
Alice, Bob and Carol are part of the same team. You are given an array of distinct integers X and another array T which is a permutation of X.
The three of them are each given a copy of X and T. Each of them has to arrange elements in X such that it becomes equal to T.
X and put it at any position of X.X and put it any position of X.X and put it at any position in X.Let the minimum number of operations be A, B, C for Alice, Bob and Carol repectively. Return A+B+C.
Example:
INPUT
X = [1,5,3,7,9]
T = [9,7,3,5,1]OUTPUT
12Explanation: Alice requires 4 operations, Bob requires 4 operations and Carol requires 4 operations. So total = 12. A sequence of operations for Alice may look like this [1,5,3,7,9] -> [5,3,7,9,1] -> [3,7,9,5,1] -> [7,9,3,5,1] -> [9,7,3,5,1].