A piecewise linear function is defined by its slope changes. If slope goes from to at , we store . observation: we only need the breakpoints, not the full function.
The slopes between breakpoints are implicit. Two heaps: (max-heap) for left breakpoints, (min-heap) for right breakpoints. The minimum is in the 'valley'. To add : insert into both and . Then balance: if , swap and adjust the base value.