Histograms
Time limit1sMemory limit256 MB
Given histogram H and point set S, build a valid histogram from S points that minimizes diffcount or abserror against H.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Prefix sum
- Solved
- No attempts yet
Problem
A histogram represents a data distribution. Here a histogram of width is given by an even-length sequence of points
in the plane. Each adjacent pair shares an or a coordinate, and horizontal and vertical segments alternate.
The shape must satisfy:
For histogram , let be the height on unit interval . Two error measures are used:
Given , a point set , and the measure , find a histogram that uses only points from and minimizes the chosen error.
Input
Line 1: integers (, even, , ). selects diffcount, selects abserror.
Next lines: points defining histogram .
Next lines: points in set . (, )
Output
Line 1: minimum error .
Line 2: even integer , the number of points in the optimal histogram.
Next lines: coordinates of those points. The definition must satisfy every rule from the statement.