Please read the new rule regarding the restriction on the use of AI tools. ×

Hard problem over Dynamic programing Any body can solve it?

Revision en1, by nHimanshu, 2023-10-23 20:21:17

The following tasks can be performed on an array of integers: 1.Choose a subarray of arr of size 1 at most x times. 2.Choose a subarray of arr of size 2 at most y times. 3.Choose a subarray of arr of size 3 at most z times.

The chosen subarrays should be non-overlapping. The profit is calculated as the sum of the elements maximum profit that can be obtained?

For example,consider the array [1,2,3,4,5] for x,y,and z exqual 1. for x=1 ,choose any one element from the array. The maximum element is 5,so chose that one.it is the maximum profit under this scenario. For y=1,choose andy subarray of two elements:[1,2],[2,3],3,4] or [4,5].The last subarray has the highest sum (profit)of 9. for z=1,the maximum profit is obatained with the subarray [3,4,5] with a sum of 12.

if you can choose one of each, maximum profit would be obtained by ignoring x then using y and z to capture [1,2] and [3,4,5] or [1,2,3] and [4,5] for a total profit of 15.

Constraints: 1<=n<=200 -10^5<=arr[i]<=10^5 0<=x,y,z<=20

Sample Case 0 Sample input 0 n=2 arr[5,3] x=1 y=0 z=0 output 5

Sampe Case 1: n=4 arr[-7,4,0,-7] x=0 y=1 z=0 output 4

What I have tried:

I am not able to find who to solve this question

Tags c++, ioi 2007 test data, hard problem, icpc

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English nHimanshu 2023-10-23 20:21:17 1291 Initial revision (published)