Another coding problem

Revision en2, by PizzaPasta, 2023-12-14 14:28:04

I met another problem (at the same forum) that has a tag of "data structures" but I can't seem to find a solution.

Given an array of n elements, divide into the minimum number of consecutive of subarrays that satifies the following conditions or determine if that is impossible:

  • Every element belongs to an exact subarray

  • The median of each subarray must be non-negative

  • Let array B be the array of the medians of the subarrays. The average of all elements of B must be be d (d is given)

  • Let array C be the array of the averages of each subarray. The median of C should be k (k is given)

  • B and C are both non-decreasing.

Please help. Thank you in advance!


  Rev. Lang. By When Δ Comment
en2 English PizzaPasta 2023-12-14 14:28:04 0 (published)
en1 English PizzaPasta 2023-12-14 14:27:49 708 Initial revision (saved to drafts)