### PizzaPasta's blog

By PizzaPasta, history, 6 months ago,

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.

• 0

By PizzaPasta, history, 6 months ago,

Hi there!

I just encountered a problem on a forum seemingly uses DSU, but there is a query that makes me question my DSU.

There are a number n and n numbers that follow. There are 3 queries: + Put a and b together + Seperate a and b + Determine whether a and b is connected

I am thinking of a reverse-DSU technique.