Блог пользователя hoacrux

Автор hoacrux, история, 4 года назад, По-русски

decompose an array of size N into contiguous subarrays of size A each chooses exactly B elements out of n elements from the original array such that

1) every continuous subarray has at least one element in common with the chosen elements and 2) sum of chosen elements is maximum

constraints

1<=N<=100 1<=A<=100 1<=B<=100 1<=A[i]<=10^6

Return the maximum sum all the chosen elements

My first approach is Pick Maximum element in a subarray of size A , and store these maximum in a set Now while set size is less than B pick larger elements which are not in set.

But that is not giving correct answer?

Can anybody tell the approach for this problem effectively?

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится