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

tourist I dare you to solve this

Revision en1, by abcuvw, 2023-09-24 17:58:55

I solved this problem using recursive memoization. Can anyone help me with iterative approach? Problem is as follows:

You are given an array A consisting of N numbers. In one move, you can either delete the first two, the last two or the first and last elements of A. No move can be performed if the length of array is less than 2. The result of each move is the sum of deleted elements. Find the maximum number of moves that can be performed such that all moves have same result.

Ex: A= [3,1,5,3,3,4,2] has max number of moves = 3 with result being 6 each time.

N<=1000 and A[i]<=1e9.

Tags dp, computer programmer, cpp, codeforces

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English abcuvw 2023-09-24 17:58:55 627 Initial revision (published)