Hah well my two downvotes here and two corresponding lost points say otherwise. But I'll take your word for it.
The equation ends up looking something like this: https://slack-files.com/TEGQB8GNS-F01UU5FMKRR-820b186081
Once you start thinking about it in terms of the definite integrals of a piecewise function you'll see where the weights would be applied in more extreme situations.