  We solve a problem of filling a given partially ordered set (that contains a
finite number of elements) by a prescribed set of values from a linearly
ordered set that minimizes (maximizes) the sum of values on a fixed set of
positions. We also apply the obtained solution of this discrete extremal
problem to two continuous extremal problems. In the first problem we find
extremal values for a line integral of a coordinate-wise monotone function of
two variables from a rearrangement-invariant class of functions. In the second
one we find extremal values for the expectation of a random process with
monotone trajectories at a random time.
