Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

tourist I dare you to solve this

Правка en1, от 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.

Теги dp, computer programmer, cpp, codeforces

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский abcuvw 2023-09-24 17:58:55 627 Initial revision (published)