Computer Science, asked by eezysameeksha, 9 months ago

Two friends A and B are playing with an array of integers. They both agree upon the operations to be performed on the array but differ on choice of window size to perform the said operations. The operations to be performed on the array are explained below: · One can choose to add at the most X consecutive elements. · After performing the addition operation, it is mandatory to skip the next element in the array. · The goal is to achieve maximum sum by choosing appropriate elements in the array. A wants X to be W, while B wants X to be (W + D). This is the only difference that they have. Your task is to find out who wins. Winner is the person whose sum is higher. The inputs that will be provided are values of elements of array, value of W and value of D. Example: Array: 4 5 6 1 2 7 8 9 Window Size (W): 3 Output: 39 Explanation · We will choose to add elements 4, 5, 6 since window size is 3. · Since one addition operation is complete, we have to skip one element which is 1. · We choose to skip element 2 because the next three values are also higher than 2. · The max sum thus obtained is 39. Now suppose the array was: 4 5 6 1 2 3 7 8 9 · We will choose to add elements 4, 5, 6 since window size is 3. · Since one addition operation is complete, we have to skip one element which is 1. · Now we choose to pick element 2 because we can skip element 3 and still pick up the next 3 values viz 7, 8, 9. · The max sum thus obtained is 41. · Note that we picked up only one element in second selection since constraint is only on maximum number to be chosen, not minimum. Now suppose the array was: 4 5 6 7 · Since one can start from any index, we choose element 5, 6, 7. · The max sum thus obtained is 18. The above examples illustrate the game with a fixed window size of W. Since B prefers to play the same game with the size of W+D, the steps will remain the same but the max sum output may be different. Print different output depending on whether A wins, B wins or it’s a tie.

Answers

Answered by shresthakrishnna
4

Answer:

GM gngfh,xsg Susan decal HDD Chen username sharp as a good night r u gonna EA sports day ❤️❤️ tqu di kata to u jann you tq I will follow up with the following link unsubscribe at any time to u jann bdh to the drop down list of the time to u VT and RR to u of the time to meet you there will be in the drop down to u

Similar questions