Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

Decompose Array into each of size N

Правка ru1, от hoacrux, 2021-02-21 11:09:25

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?

Теги array, #greedy

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
ru1 Русский hoacrux 2021-02-21 11:09:25 745 First edition (опубликовано)